From 16a8424b80b5fbcb8b59787fecbf06d2d8ea8d80 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Mon, 17 Sep 2018 20:15:30 +0200 Subject: [PATCH 01/16] logs on linux in /var/log/boswatch/ on windows in log/ folder --- boswatch/utils/paths.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/boswatch/utils/paths.py b/boswatch/utils/paths.py index eac59b2..3c0fe8d 100644 --- a/boswatch/utils/paths.py +++ b/boswatch/utils/paths.py @@ -17,12 +17,18 @@ import logging import os import sys +import platform logging.debug("- %s loaded", __name__) # todo searching for root part is not a nice solution atm ROOT_PATH = os.path.dirname(sys.modules['boswatch'].__file__).replace("\\", "/") + "/../" -LOG_PATH = ROOT_PATH + "log/" + +if platform.system() is "Linux": + LOG_PATH = "/var/log/boswatch/" +else: + LOG_PATH = ROOT_PATH + "log/" + CONFIG_PATH = ROOT_PATH + "config/" PLUGIN_PATH = ROOT_PATH + "plugins/" CSV_PATH = ROOT_PATH + "csv/" From a6e10dd6f562846c89117d4b308b58c4b5bbf796 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Tue, 18 Sep 2018 05:48:18 +0200 Subject: [PATCH 02/16] fix error --- boswatch/utils/paths.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boswatch/utils/paths.py b/boswatch/utils/paths.py index 3c0fe8d..9b52f12 100644 --- a/boswatch/utils/paths.py +++ b/boswatch/utils/paths.py @@ -24,7 +24,7 @@ logging.debug("- %s loaded", __name__) # todo searching for root part is not a nice solution atm ROOT_PATH = os.path.dirname(sys.modules['boswatch'].__file__).replace("\\", "/") + "/../" -if platform.system() is "Linux": +if platform.system() == "Linux": LOG_PATH = "/var/log/boswatch/" else: LOG_PATH = ROOT_PATH + "log/" From 63117a4bc54df6f361c0840c8abb83f0adb68fa9 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Wed, 19 Sep 2018 14:52:10 +0200 Subject: [PATCH 03/16] fix error --- plugins/template/template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/template/template.py b/plugins/template/template.py index f570a52..de1b78a 100644 --- a/plugins/template/template.py +++ b/plugins/template/template.py @@ -30,7 +30,7 @@ class BoswatchPlugin(Plugin): def __init__(self): """!Do not change anything here except the PLUGIN NAME in the super() call""" # PLEASE SET YOU PLUGIN NAME HERE !!!! - Plugin.__init__("template") + super().__init__("template") def onLoad(self): """!Called by import of the plugin""" From d95ab7781ed38ab674db550abe9b4847a279923e Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Wed, 19 Sep 2018 14:53:56 +0200 Subject: [PATCH 04/16] combine some todos --- boswatch/filter/doubeFilter.py | 3 +-- boswatch/utils/wildcard.py | 1 - bw_client.py | 3 +-- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/boswatch/filter/doubeFilter.py b/boswatch/filter/doubeFilter.py index 066e18d..c230155 100644 --- a/boswatch/filter/doubeFilter.py +++ b/boswatch/filter/doubeFilter.py @@ -13,8 +13,7 @@ @date: 15.01.2018 @author: Bastian Schroll @description: Class to implement a filter for double alarms -@todo test, refactor and document -@todo check_msg is not implemented yet +@todo test, refactor and document / check_msg is not implemented yet """ import logging import time diff --git a/boswatch/utils/wildcard.py b/boswatch/utils/wildcard.py index 636b27c..dc0f746 100644 --- a/boswatch/utils/wildcard.py +++ b/boswatch/utils/wildcard.py @@ -13,7 +13,6 @@ @date: 15.01.2018 @author: Bastian Schroll @description: Little Helper to replace wildcards in stings -@todo not completed yet """ import logging import time diff --git a/bw_client.py b/bw_client.py index 29fee0f..530abe5 100644 --- a/bw_client.py +++ b/bw_client.py @@ -91,8 +91,7 @@ try: bwPacket.addClientData() bwClient.transmit(str(bwPacket)) - # todo should we do this in an thread, to not block receiving ??? - # todo but then we should use transmit() and receive() with Lock() + # todo should we do this in an thread, to not block receiving ??? but then we should use transmit() and receive() with Lock() failedTransmits = 0 while not bwClient.receive() == "[ack]": # wait for ack or timeout if failedTransmits >= 3: From 2037921ee669f54dcb1849cb200588edb4f91cef Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Wed, 19 Sep 2018 15:09:30 +0200 Subject: [PATCH 05/16] change a todo to note --- boswatch/utils/paths.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boswatch/utils/paths.py b/boswatch/utils/paths.py index 9b52f12..c553e3a 100644 --- a/boswatch/utils/paths.py +++ b/boswatch/utils/paths.py @@ -21,7 +21,7 @@ import platform logging.debug("- %s loaded", __name__) -# todo searching for root part is not a nice solution atm +# note searching for root part is not a nice solution atm ROOT_PATH = os.path.dirname(sys.modules['boswatch'].__file__).replace("\\", "/") + "/../" if platform.system() == "Linux": From 1435d80f0fafad2d63bc90156af9ac15b04a7f6a Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Thu, 20 Sep 2018 07:31:21 +0200 Subject: [PATCH 06/16] change import order --- test/test_ServerClient.py | 2 +- test/test_packet.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_ServerClient.py b/test/test_ServerClient.py index 48b030c..37e7ff2 100644 --- a/test/test_ServerClient.py +++ b/test/test_ServerClient.py @@ -14,8 +14,8 @@ @author: Bastian Schroll @description: Unittests for BOSWatch. File must be _run as "pytest" unittest """ -import pytest import logging +import pytest import time from boswatch.network.server import TCPServer diff --git a/test/test_packet.py b/test/test_packet.py index f311a22..77fef07 100644 --- a/test/test_packet.py +++ b/test/test_packet.py @@ -14,8 +14,8 @@ @author: Bastian Schroll @description: Unittests for BOSWatch. File must be _run as "pytest" unittest """ -import pytest import logging +import pytest from boswatch.packet.packet import Packet From 1d30c991808a19c1d32590110c4aa91c1694d902 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Thu, 20 Sep 2018 07:37:10 +0200 Subject: [PATCH 07/16] change import order from pytest --- test/test_ServerClient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_ServerClient.py b/test/test_ServerClient.py index 37e7ff2..a4398f5 100644 --- a/test/test_ServerClient.py +++ b/test/test_ServerClient.py @@ -15,8 +15,8 @@ @description: Unittests for BOSWatch. File must be _run as "pytest" unittest """ import logging -import pytest import time +import pytest from boswatch.network.server import TCPServer from boswatch.network.client import TCPClient From 1252a953a8f9b68290567d3c23953e74b6748ac8 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Thu, 20 Sep 2018 07:58:26 +0200 Subject: [PATCH 08/16] add doc to server.py --- boswatch/network/server.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/boswatch/network/server.py b/boswatch/network/server.py index 9dd6567..f3a4be0 100644 --- a/boswatch/network/server.py +++ b/boswatch/network/server.py @@ -135,7 +135,11 @@ class TCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer): @staticmethod def getClientsConnected(): - # todo insert comment + """!A list of all connected clients + with their IP address and last seen timestamp + _clients[ThreadName] = {"address", "timestamp"} + + @return List of onnected clients""" # todo return full list or write a print/debug method? return _clients From aca20faf18aa40455e9f755e823547712f5696d6 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Thu, 20 Sep 2018 08:02:42 +0200 Subject: [PATCH 09/16] add comment --- boswatch/utils/paths.py | 1 + 1 file changed, 1 insertion(+) diff --git a/boswatch/utils/paths.py b/boswatch/utils/paths.py index c553e3a..b1078de 100644 --- a/boswatch/utils/paths.py +++ b/boswatch/utils/paths.py @@ -24,6 +24,7 @@ logging.debug("- %s loaded", __name__) # note searching for root part is not a nice solution atm ROOT_PATH = os.path.dirname(sys.modules['boswatch'].__file__).replace("\\", "/") + "/../" +# here a system adaption for the paths can be implemented if platform.system() == "Linux": LOG_PATH = "/var/log/boswatch/" else: From 478868c225f94961782c1e848f78d4440a9fcef0 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Thu, 20 Sep 2018 08:10:40 +0200 Subject: [PATCH 10/16] change comment --- boswatch/utils/paths.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boswatch/utils/paths.py b/boswatch/utils/paths.py index b1078de..d9cfb48 100644 --- a/boswatch/utils/paths.py +++ b/boswatch/utils/paths.py @@ -24,7 +24,7 @@ logging.debug("- %s loaded", __name__) # note searching for root part is not a nice solution atm ROOT_PATH = os.path.dirname(sys.modules['boswatch'].__file__).replace("\\", "/") + "/../" -# here a system adaption for the paths can be implemented +# implements a system adaption for the paths if platform.system() == "Linux": LOG_PATH = "/var/log/boswatch/" else: From 449c8f97261c81649bde7a0bc491266bc8142099 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Thu, 20 Sep 2018 09:51:47 +0200 Subject: [PATCH 11/16] add system adaption for config path --- boswatch/utils/paths.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/boswatch/utils/paths.py b/boswatch/utils/paths.py index d9cfb48..ea1766d 100644 --- a/boswatch/utils/paths.py +++ b/boswatch/utils/paths.py @@ -27,10 +27,11 @@ ROOT_PATH = os.path.dirname(sys.modules['boswatch'].__file__).replace("\\", "/") # implements a system adaption for the paths if platform.system() == "Linux": LOG_PATH = "/var/log/boswatch/" + CONFIG_PATH = "/etc/boswatch/" else: LOG_PATH = ROOT_PATH + "log/" + CONFIG_PATH = ROOT_PATH + "config/" -CONFIG_PATH = ROOT_PATH + "config/" PLUGIN_PATH = ROOT_PATH + "plugins/" CSV_PATH = ROOT_PATH + "csv/" BIN_PATH = ROOT_PATH + "_bin/" From f0081d6e6dc774fd16cbd9ccbf12a6d29ff5b579 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Thu, 20 Sep 2018 10:53:09 +0200 Subject: [PATCH 12/16] fix path --- boswatch/utils/paths.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boswatch/utils/paths.py b/boswatch/utils/paths.py index ea1766d..9f57498 100644 --- a/boswatch/utils/paths.py +++ b/boswatch/utils/paths.py @@ -27,7 +27,7 @@ ROOT_PATH = os.path.dirname(sys.modules['boswatch'].__file__).replace("\\", "/") # implements a system adaption for the paths if platform.system() == "Linux": LOG_PATH = "/var/log/boswatch/" - CONFIG_PATH = "/etc/boswatch/" + CONFIG_PATH = "/etc/opt/boswatch/" else: LOG_PATH = ROOT_PATH + "log/" CONFIG_PATH = ROOT_PATH + "config/" From d08381108fc5e576928d80475241fd867ad0ee59 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Thu, 20 Sep 2018 14:19:51 +0200 Subject: [PATCH 13/16] fix false type from _clients in server.py --- boswatch/network/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boswatch/network/server.py b/boswatch/network/server.py index 9dd6567..429ce85 100644 --- a/boswatch/network/server.py +++ b/boswatch/network/server.py @@ -26,7 +26,7 @@ _dataPackets = [] _lockDataPackets = threading.Lock() # module wide global list for all currently connected clients -_clients = {} # _clients[ThreadName] = {"address", "timestamp"} +_clients = [] # _clients[ThreadName] = {"address", "timestamp"} _lockClients = threading.Lock() From c90327614160e67703c30911a9727eada50cc3b1 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Thu, 20 Sep 2018 14:19:51 +0200 Subject: [PATCH 14/16] Revert "fix false type from _clients in server.py" This reverts commit d08381108fc5e576928d80475241fd867ad0ee59. --- boswatch/network/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boswatch/network/server.py b/boswatch/network/server.py index 429ce85..9dd6567 100644 --- a/boswatch/network/server.py +++ b/boswatch/network/server.py @@ -26,7 +26,7 @@ _dataPackets = [] _lockDataPackets = threading.Lock() # module wide global list for all currently connected clients -_clients = [] # _clients[ThreadName] = {"address", "timestamp"} +_clients = {} # _clients[ThreadName] = {"address", "timestamp"} _lockClients = threading.Lock() From da94581dc266a2560f10f4445c6df031ee759ea8 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Thu, 20 Sep 2018 23:55:53 +0200 Subject: [PATCH 15/16] fix doxy warning --- boswatch/packet/packet.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/boswatch/packet/packet.py b/boswatch/packet/packet.py index 801bc91..bf0103c 100644 --- a/boswatch/packet/packet.py +++ b/boswatch/packet/packet.py @@ -101,6 +101,5 @@ class Packet: """!Print a info message to the log on INFO level. Contains the most useful info about this packet. @todo not complete yet - must be edit to print nice formatted messages on console - - @param bwPacket: BOSWatch packet instance""" + """ logging.info("[%s]", self.get("mode")) From ff8e1347bd4e9ba32bbb8f8f658f307f1bbc7273 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Fri, 21 Sep 2018 12:43:43 +0200 Subject: [PATCH 16/16] add fixme warning --- boswatch/utils/paths.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/boswatch/utils/paths.py b/boswatch/utils/paths.py index 9f57498..d3f00a7 100644 --- a/boswatch/utils/paths.py +++ b/boswatch/utils/paths.py @@ -29,6 +29,8 @@ if platform.system() == "Linux": LOG_PATH = "/var/log/boswatch/" CONFIG_PATH = "/etc/opt/boswatch/" else: + # FIXME LOG_PATH not used actually + # path is fixed in logger config.ini LOG_PATH = ROOT_PATH + "log/" CONFIG_PATH = ROOT_PATH + "config/"