From fd501c23dcd7f1cdafb4869d3ef9a5c1f6ccbc66 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Sat, 3 Feb 2018 22:32:28 +0100 Subject: [PATCH] some little improvements --- boswatch/decoder/fms.py | 2 +- boswatch/decoder/pocsag.py | 2 +- boswatch/decoder/zvei.py | 2 +- boswatch/filter/doubeFilter.py | 4 ++-- boswatch/network/server.py | 8 +++++--- boswatch/packet/packet.py | 2 +- test/test_ServerClient.py | 8 ++++---- 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/boswatch/decoder/fms.py b/boswatch/decoder/fms.py index 79634b2..136594f 100644 --- a/boswatch/decoder/fms.py +++ b/boswatch/decoder/fms.py @@ -27,7 +27,7 @@ class Fms: """!FMS decoder class This class decodes FMS data. - First step is to validate the data and check if the format is correct. + First step is to validate the data and _check if the format is correct. In the last step a valid BOSWatch packet is created and returned""" def __init__(self): diff --git a/boswatch/decoder/pocsag.py b/boswatch/decoder/pocsag.py index 62ac7b3..993a72a 100644 --- a/boswatch/decoder/pocsag.py +++ b/boswatch/decoder/pocsag.py @@ -27,7 +27,7 @@ class Pocsag: """!POCSAG decoder class This class decodes POCSAG data. - First step is to validate the data and check if the format is correct. + First step is to validate the data and _check if the format is correct. In the last step a valid BOSWatch packet is created and returned""" def __init__(self): diff --git a/boswatch/decoder/zvei.py b/boswatch/decoder/zvei.py index 4f42c1e..7b17959 100644 --- a/boswatch/decoder/zvei.py +++ b/boswatch/decoder/zvei.py @@ -27,7 +27,7 @@ class Zvei: """!ZVEI decoder class This class decodes ZVEI data. - First step is to validate the data and check if the format is correct. + First step is to validate the data and _check if the format is correct. After that the double-tone-sign 'E' is replaced. In the last step a valid BOSWatch packet is created and returned""" diff --git a/boswatch/filter/doubeFilter.py b/boswatch/filter/doubeFilter.py index 60747b0..6e02bc9 100644 --- a/boswatch/filter/doubeFilter.py +++ b/boswatch/filter/doubeFilter.py @@ -53,9 +53,9 @@ class DoubleFilter: logging.debug("scanWord for '%s' is '%s'", bwPacket.get("mode"), scanWord) - return self.check(bwPacket, scanWord) + return self._check(bwPacket, scanWord) - def check(self, bwPacket, scanWord): + def _check(self, bwPacket, scanWord): self._filterLists[bwPacket.get("mode")].insert(0, bwPacket) # delete entrys that are to old diff --git a/boswatch/network/server.py b/boswatch/network/server.py index af3641c..cb9a1e3 100644 --- a/boswatch/network/server.py +++ b/boswatch/network/server.py @@ -21,10 +21,12 @@ import time logging.debug("- %s loaded", __name__) -_dataPackets = [] # module wide global list for received data sets +# module wide global list for received data sets +_dataPackets = [] _lockDataPackets = threading.Lock() -_clients = {} +# module wide global list for all currently connected clients +_clients = {} # _clients[ThreadName] = {"address", "timestamp"} _lockClients = threading.Lock() @@ -138,7 +140,7 @@ class TCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer): return _clients @staticmethod - def getData(): + def getDataFromQueue(): """!Function to get the data packages from server must be polled by main program diff --git a/boswatch/packet/packet.py b/boswatch/packet/packet.py index c761d34..c7b98e5 100644 --- a/boswatch/packet/packet.py +++ b/boswatch/packet/packet.py @@ -36,7 +36,7 @@ class Packet: logging.debug("create bwPacket from string") try: self._packet = eval(str(bwPacket.strip())) - except: + except: # pragma: no cover # todo can we repair the packet anyway? logging.exception("error while create packet from string") diff --git a/test/test_ServerClient.py b/test/test_ServerClient.py index 9ab2a90..828d9f9 100644 --- a/test/test_ServerClient.py +++ b/test/test_ServerClient.py @@ -149,10 +149,10 @@ class Test_ServerClient: # recv all assert self.testClient1.receive() == "[ack]" assert self.testClient2.receive() == "[ack]" - # check server output data - assert useServer.getData()[1] == "test1" - assert useServer.getData()[1] == "test2" - assert useServer.getData() is None # Last check must be None + # _check server output data + assert useServer.getDataFromQueue()[1] == "test1" + assert useServer.getDataFromQueue()[1] == "test2" + assert useServer.getDataFromQueue() is None # Last _check must be None # disconnect all assert self.testClient1.disconnect() assert self.testClient2.disconnect()