Merge branch 'develop' into server_queue

This commit is contained in:
Bastian Schroll 2018-09-21 12:53:06 +02:00 committed by GitHub
commit c2b3093bb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 21 additions and 14 deletions

View file

@ -13,8 +13,7 @@
@date: 15.01.2018 @date: 15.01.2018
@author: Bastian Schroll @author: Bastian Schroll
@description: Class to implement a filter for double alarms @description: Class to implement a filter for double alarms
@todo test, refactor and document @todo test, refactor and document / check_msg is not implemented yet
@todo check_msg is not implemented yet
""" """
import logging import logging
import time import time

View file

@ -140,9 +140,10 @@ class TCPServer:
@staticmethod @staticmethod
def getClientsConnected(): def getClientsConnected():
"""!List of currently connected Clients """!A list of all connected clients
with their IP address and last seen timestamp
_clients[ThreadName] = {"address", "timestamp"} _clients[ThreadName] = {"address", "timestamp"}
@return List of connected clients""" @return List of onnected clients"""
# todo return full list or write a print/debug method? # todo return full list or write a print/debug method?
return _clients return _clients

View file

@ -101,6 +101,5 @@ class Packet:
"""!Print a info message to the log on INFO level. """!Print a info message to the log on INFO level.
Contains the most useful info about this packet. Contains the most useful info about this packet.
@todo not complete yet - must be edit to print nice formatted messages on console @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")) logging.info("[%s]", self.get("mode"))

View file

@ -17,13 +17,23 @@
import logging import logging
import os import os
import sys import sys
import platform
logging.debug("- %s loaded", __name__) 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("\\", "/") + "/../" ROOT_PATH = os.path.dirname(sys.modules['boswatch'].__file__).replace("\\", "/") + "/../"
LOG_PATH = ROOT_PATH + "log/"
CONFIG_PATH = ROOT_PATH + "config/" # implements a system adaption for the paths
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/"
PLUGIN_PATH = ROOT_PATH + "plugins/" PLUGIN_PATH = ROOT_PATH + "plugins/"
CSV_PATH = ROOT_PATH + "csv/" CSV_PATH = ROOT_PATH + "csv/"
BIN_PATH = ROOT_PATH + "_bin/" BIN_PATH = ROOT_PATH + "_bin/"

View file

@ -13,7 +13,6 @@
@date: 15.01.2018 @date: 15.01.2018
@author: Bastian Schroll @author: Bastian Schroll
@description: Little Helper to replace wildcards in stings @description: Little Helper to replace wildcards in stings
@todo not completed yet
""" """
import logging import logging
import time import time

View file

@ -91,8 +91,7 @@ try:
bwPacket.addClientData() bwPacket.addClientData()
bwClient.transmit(str(bwPacket)) bwClient.transmit(str(bwPacket))
# todo should we do this in an thread, to not block receiving ??? # todo should we do this in an thread, to not block receiving ??? but then we should use transmit() and receive() with Lock()
# todo but then we should use transmit() and receive() with Lock()
failedTransmits = 0 failedTransmits = 0
while not bwClient.receive() == "[ack]": # wait for ack or timeout while not bwClient.receive() == "[ack]": # wait for ack or timeout
if failedTransmits >= 3: if failedTransmits >= 3:

View file

@ -14,10 +14,10 @@
@author: Bastian Schroll @author: Bastian Schroll
@description: Unittests for BOSWatch. File must be _run as "pytest" unittest @description: Unittests for BOSWatch. File must be _run as "pytest" unittest
""" """
import pytest
import logging import logging
import time import time
import queue import queue
import pytest
from boswatch.network.server import TCPServer from boswatch.network.server import TCPServer
from boswatch.network.client import TCPClient from boswatch.network.client import TCPClient

View file

@ -14,8 +14,8 @@
@author: Bastian Schroll @author: Bastian Schroll
@description: Unittests for BOSWatch. File must be _run as "pytest" unittest @description: Unittests for BOSWatch. File must be _run as "pytest" unittest
""" """
import pytest
import logging import logging
import pytest
from boswatch.packet.packet import Packet from boswatch.packet.packet import Packet