diff --git a/.idea/revpipyload.iml b/.idea/revpipyload.iml index 179692b..7ece66a 100644 --- a/.idea/revpipyload.iml +++ b/.idea/revpipyload.iml @@ -8,7 +8,4 @@ - - \ No newline at end of file diff --git a/revpipyload/helper.py b/revpipyload/helper.py index 936b3ee..1f7b1f5 100644 --- a/revpipyload/helper.py +++ b/revpipyload/helper.py @@ -140,6 +140,9 @@ def get_revpiled_address(configrsc_bytes): if device.get("type", "") == "BASE": try: byte_address = device["offset"] + int(device["out"]["0"][3]) + if device.get("productType", "0") == "135": + # On the Flat device the LEDs are 2 Bytes (last Bit is wd) + byte_address += 1 proginit.logger.debug( "found revpi_led_address on {0} byte".format(byte_address) ) diff --git a/revpipyload/logsystem.py b/revpipyload/logsystem.py index 3382999..4e182eb 100644 --- a/revpipyload/logsystem.py +++ b/revpipyload/logsystem.py @@ -18,6 +18,9 @@ class LogReader: """ + MAX_UPLOAD_SIZE = 1048576 + """Maximum block of logfile.""" + def __init__(self): """Instantiiert LogReader-Klasse.""" self.fhapp = None @@ -40,10 +43,17 @@ class LogReader: @return Binary() der Logdatei """ + # Max block to prevent freeze + if count > self.MAX_UPLOAD_SIZE: + raise ValueError( + "Parameter count has a max value of {0}" + "".format(self.MAX_UPLOAD_SIZE) + ) + if not os.access(proginit.logapp, os.R_OK): - return Binary(b'\x16') #  + return Binary(b'\x16') # ESC elif start > os.path.getsize(proginit.logapp): - return Binary(b'\x19') #  + return Binary(b'\x19') # EM else: with self.fhapplk: if self.fhapp is None or self.fhapp.closed: @@ -60,10 +70,17 @@ class LogReader: @return Binary() der Logdatei """ + # Max block to prevent freeze + if count > self.MAX_UPLOAD_SIZE: + raise ValueError( + "Parameter count has a max value of {0}" + "".format(self.MAX_UPLOAD_SIZE) + ) + if not os.access(proginit.logplc, os.R_OK): - return Binary(b'\x16') #  + return Binary(b'\x16') # ESC elif start > os.path.getsize(proginit.logplc): - return Binary(b'\x19') #  + return Binary(b'\x19') # EM else: with self.fhplclk: if self.fhplc is None or self.fhplc.closed: diff --git a/revpipyload/revpipyload.py b/revpipyload/revpipyload.py index 8662ea3..bce4e94 100755 --- a/revpipyload/revpipyload.py +++ b/revpipyload/revpipyload.py @@ -41,7 +41,7 @@ from json import loads as jloads from shutil import rmtree from tempfile import mkstemp from threading import Event -from time import asctime +from time import asctime, time from xmlrpc.client import Binary import logsystem @@ -876,10 +876,12 @@ class RevPiPyLoad: self.th_plcslave.start() if self.xmlrpc and self.xsrv is not None: - # Work xml calls in same thread or wait till timeout - self.xsrv.handle_request() + # Work multiple xml calls in same thread until timeout + xml_start = time() + while time() - xml_start < 1.0: + self.xsrv.handle_request() else: - self.evt_loadconfig.wait(1) + self.evt_loadconfig.wait(1.0) proginit.logger.info("stopping revpipyload") diff --git a/revpipyload/xrpcserver.py b/revpipyload/xrpcserver.py index 2e7cb8e..f4688ed 100644 --- a/revpipyload/xrpcserver.py +++ b/revpipyload/xrpcserver.py @@ -83,6 +83,8 @@ class SaveXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): """Verwaltet die XML-Requests und prueft Berechtigungen.""" + timeout = 2.0 + def parse_request(self): """Berechtigungen pruefen. @return True, wenn Parsen erfolgreich war""" diff --git a/setup.py b/setup.py index f9a2150..5d90a11 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ setup( license="LGPLv3", name="revpipyload", - version="0.9.2b", + version="0.9.2c", scripts=[ "data/revpipyload",