From f0d19eaba0a1a4cad4ec8a1b745393c46e584ab4 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Sat, 13 Jan 2018 09:56:46 +0100 Subject: [PATCH] some little changes --- _info/functions.txt | 4 +++- boswatch/network/client.py | 3 +++ boswatch/network/server.py | 6 +++--- boswatch/packet/packet.py | 2 +- boswatch/utils/paths.py | 14 +++++++------- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/_info/functions.txt b/_info/functions.txt index 55d8fb1..5b38760 100644 --- a/_info/functions.txt +++ b/_info/functions.txt @@ -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 \ No newline at end of file +Alarm-Daten Übermittlung per definierten bwPacket-Paket +Plugin Statistiken sowie Ausführungszeiten +Funktionaler und dynamischer Pluginloader diff --git a/boswatch/network/client.py b/boswatch/network/client.py index 3e66b67..32808c2 100644 --- a/boswatch/network/client.py +++ b/boswatch/network/client.py @@ -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 diff --git a/boswatch/network/server.py b/boswatch/network/server.py index 2aa820e..9b99064 100644 --- a/boswatch/network/server.py +++ b/boswatch/network/server.py @@ -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(): diff --git a/boswatch/packet/packet.py b/boswatch/packet/packet.py index d2f3670..a0353cf 100644 --- a/boswatch/packet/packet.py +++ b/boswatch/packet/packet.py @@ -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")) diff --git a/boswatch/utils/paths.py b/boswatch/utils/paths.py index 040a930..393a532 100644 --- a/boswatch/utils/paths.py +++ b/boswatch/utils/paths.py @@ -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):