some little changes

This commit is contained in:
Bastian Schroll 2018-01-13 09:56:46 +01:00
parent 9c38eeaac0
commit f0d19eaba0
5 changed files with 17 additions and 12 deletions

View file

@ -9,4 +9,6 @@ Komfortables Plugin System
Ausführliche Plugin Statistiken
Beschreibung aus CSV File
Konfigurationsdateien Modulweit teilbar über "Sharepoints"
Alarm-Daten Übermittlung per definierten bwPacket-Paket
Alarm-Daten Übermittlung per definierten bwPacket-Paket
Plugin Statistiken sowie Ausführungszeiten
Funktionaler und dynamischer Pluginloader

View file

@ -102,6 +102,9 @@ class TCPClient:
except AttributeError:
logging.error("cannot receive - no connection established")
return False
except ConnectionResetError:
logging.error("cannot receive - host closed connection")
return False
except: # pragma: no cover
logging.exception("error while receiving")
return False

View file

@ -43,7 +43,7 @@ class TCPHandler(socketserver.BaseRequestHandler):
logging.debug(req_name + " recv: " + data)
# add a new entry at first position (index 0) with client IP
# and the decoded data dict as an string in utf-8
# and the decoded data dict as an string in utf-8 and an timestamp
# lock.acquire() # todo check if needed - only append not modify data
with _lockClients:
_clients.insert(0, (self.client_address[0], data, time.time())) # time() to calc time in queue
@ -133,7 +133,7 @@ class TCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
@return Next data packet.py from intern queue"""
if _clients:
# lock.acquire() # todo check if needed - only append not modify data
# lock.acquire() # todo check if needed - here is a modify of the list?
with _lockClients:
message = _clients.pop()
# lock.release() # todo check if needed
@ -146,7 +146,7 @@ class TCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
"""!Get packets waiting in queue
@return Packets in queue"""
return len(_clients)
return len(_clients) # no lock needed - only reading
@staticmethod
def flushData():

View file

@ -99,4 +99,4 @@ class Packet:
@todo not complete yet - must be edit to print nice formatted messages on console
@param bwPacket: BOSWatch packet instance"""
logging.info("%s packet received", self.get("mode"))
logging.info("[%s]", self.get("mode"))

View file

@ -20,13 +20,13 @@ import sys
logging.debug("- %s loaded", __name__)
ROOT_PATH = os.path.dirname(sys.modules['boswatch'].__file__).replace("\\boswatch", "").replace("\\", "/")
LOG_PATH = ROOT_PATH + "/log/"
CONFIG_PATH = ROOT_PATH + "/config/"
PLUGIN_PATH = ROOT_PATH + "/plugins/"
CSV_PATH = ROOT_PATH + "/csv/"
BIN_PATH = ROOT_PATH + "/_bin/"
TEST_PATH = ROOT_PATH + "/test/"
ROOT_PATH = os.path.dirname(sys.modules['boswatch'].__file__).replace("\\", "/") + "/../"
LOG_PATH = ROOT_PATH + "log/"
CONFIG_PATH = ROOT_PATH + "config/"
PLUGIN_PATH = ROOT_PATH + "plugins/"
CSV_PATH = ROOT_PATH + "csv/"
BIN_PATH = ROOT_PATH + "_bin/"
TEST_PATH = ROOT_PATH + "test/"
def ifFileExist(filePath):