satisfy pycodestyle checker
This commit is contained in:
@ -1,12 +1,14 @@
|
||||
import re
|
||||
import json
|
||||
|
||||
|
||||
class InvalidDataObjectException(Exception):
|
||||
def __init__(self, message):
|
||||
super().__init__(message)
|
||||
|
||||
|
||||
class AbstractDataObject(object):
|
||||
invalidChars = re.compile("[#+\s]")
|
||||
invalidChars = re.compile(r'[#+\s]')
|
||||
|
||||
def __init__(self, topicPart):
|
||||
self.topicPart = topicPart
|
||||
|
@ -4,7 +4,6 @@ from AbstractDataObject import AbstractDataObject
|
||||
|
||||
|
||||
class FlatDataObject(AbstractDataObject):
|
||||
|
||||
def __init__(self, serverName, nameSpaceIndex, variableName, value):
|
||||
super().__init__(serverName + '/' + str(nameSpaceIndex) + '/' + variableName)
|
||||
self.serverName = serverName
|
||||
|
@ -4,13 +4,14 @@ import threading
|
||||
import ssl
|
||||
|
||||
|
||||
|
||||
def mqttOnConnectCallback(client, userdata, flags, rc):
|
||||
userdata.onConnect()
|
||||
|
||||
|
||||
def mqttOnMessageCallback(client, userdata, message):
|
||||
userdata.onMessage(message.topic, message.payload)
|
||||
|
||||
|
||||
def mqttOnDisconnectCallback(client, userdata, rc):
|
||||
userdata.onDisconnect(rc)
|
||||
|
||||
@ -52,7 +53,6 @@ class AbstractMqttPublisher(threading.Thread):
|
||||
ciphers=None # this does not mean "no cipher" but it means "default ciphers"
|
||||
)
|
||||
|
||||
|
||||
self.client.connect(self.config["broker"], int(self.config["port"]))
|
||||
self.client.loop_start()
|
||||
logger.info("mqtt loop started")
|
||||
@ -80,4 +80,3 @@ class AbstractMqttPublisher(threading.Thread):
|
||||
|
||||
def onMessage(self, topic, payload):
|
||||
logger.warning("mqtt unexpected message received: {} -> {}".format(topic, str(payload)))
|
||||
|
||||
|
@ -7,6 +7,7 @@ import json
|
||||
|
||||
LOOP_SLICE = 0.1 # seconds
|
||||
|
||||
|
||||
class MqttPublish(AbstractMqttPublisher):
|
||||
def __init__(self, config, stats, queue):
|
||||
super().__init__(config)
|
||||
@ -32,4 +33,3 @@ class MqttPublish(AbstractMqttPublisher):
|
||||
except Exception as e:
|
||||
self.stats.incMqttErrors()
|
||||
logger.error(f"Exception {type(e)} received in MQTT local loop: {e}")
|
||||
|
||||
|
@ -5,6 +5,7 @@ from loguru import logger
|
||||
from FlatDataObject import FlatDataObject
|
||||
from StructuredDataObject import StructuredDataObject
|
||||
|
||||
|
||||
class OpcUaRequester(threading.Thread):
|
||||
def __init__(self, config, stats, queue):
|
||||
super().__init__()
|
||||
@ -25,7 +26,6 @@ class OpcUaRequester(threading.Thread):
|
||||
self.killBill = False
|
||||
self.killEvent = threading.Event()
|
||||
|
||||
|
||||
async def opcUaRequesterInnerLoop(self):
|
||||
while not self.killBill:
|
||||
try:
|
||||
@ -69,4 +69,3 @@ class OpcUaRequester(threading.Thread):
|
||||
|
||||
self.killEvent.set()
|
||||
logger.info("kill events triggered")
|
||||
|
||||
|
@ -4,6 +4,7 @@ from AbstractDataObject import AbstractDataObject
|
||||
import json
|
||||
import datetime
|
||||
|
||||
|
||||
class StatisticsDataObject(AbstractDataObject):
|
||||
def __init__(self, topic, payload):
|
||||
super().__init__(topic)
|
||||
@ -27,7 +28,7 @@ class StatisticsCollector(threading.Thread):
|
||||
|
||||
self.stats = {
|
||||
'opcUaRequests': 0,
|
||||
'opcUaErrors' : 0,
|
||||
'opcUaErrors': 0,
|
||||
'opcUaTimeouts': 0,
|
||||
'mqttRequests': 0,
|
||||
'mqttErrors': 0,
|
||||
@ -63,4 +64,3 @@ class StatisticsCollector(threading.Thread):
|
||||
self.stats['uptime'] = int((currentTime - startTime).total_seconds())
|
||||
self.queue.put(StatisticsDataObject(self.topic, self.stats))
|
||||
self.killEvent.wait(timeout=float(self.period))
|
||||
|
||||
|
@ -4,7 +4,6 @@ from AbstractDataObject import AbstractDataObject
|
||||
|
||||
|
||||
class StructuredDataObject(AbstractDataObject):
|
||||
|
||||
def __init__(self, topicPart):
|
||||
super().__init__(topicPart)
|
||||
self.keyValuePairs = []
|
||||
|
@ -12,12 +12,14 @@ import signal
|
||||
|
||||
deathBell = threading.Event()
|
||||
|
||||
|
||||
def exceptHook(args):
|
||||
global deathBell
|
||||
logger.error("Exception in thread caught: {}".format(args))
|
||||
deathBell.set()
|
||||
logger.error("rang the death bell")
|
||||
|
||||
|
||||
def terminateHook(sig, frame):
|
||||
global deathBell
|
||||
logger.error("SIGINT received")
|
||||
|
Reference in New Issue
Block a user