mirror of
https://github.com/naruxde/revpipyload.git
synced 2025-11-08 15:13:52 +01:00
XML-RPC performance, RevPi Flat soft watchdog bit
XML-RPC handle multiple request in main loop XML-RPC log system send max 1M of data XML-RPC set handler timeout to 2 seconds Add support for RevPi Flat last bit of RevPiLED word for soft watchdog
This commit is contained in:
3
.idea/revpipyload.iml
generated
3
.idea/revpipyload.iml
generated
@@ -8,7 +8,4 @@
|
|||||||
<orderEntry type="jdk" jdkName="Python 3.6 (revpi)" jdkType="Python SDK" />
|
<orderEntry type="jdk" jdkName="Python 3.6 (revpi)" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
<component name="TestRunnerService">
|
|
||||||
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
|
|
||||||
</component>
|
|
||||||
</module>
|
</module>
|
||||||
@@ -140,6 +140,9 @@ def get_revpiled_address(configrsc_bytes):
|
|||||||
if device.get("type", "") == "BASE":
|
if device.get("type", "") == "BASE":
|
||||||
try:
|
try:
|
||||||
byte_address = device["offset"] + int(device["out"]["0"][3])
|
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(
|
proginit.logger.debug(
|
||||||
"found revpi_led_address on {0} byte".format(byte_address)
|
"found revpi_led_address on {0} byte".format(byte_address)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ class LogReader:
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
MAX_UPLOAD_SIZE = 1048576
|
||||||
|
"""Maximum block of logfile."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Instantiiert LogReader-Klasse."""
|
"""Instantiiert LogReader-Klasse."""
|
||||||
self.fhapp = None
|
self.fhapp = None
|
||||||
@@ -40,10 +43,17 @@ class LogReader:
|
|||||||
@return Binary() der Logdatei
|
@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):
|
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):
|
elif start > os.path.getsize(proginit.logapp):
|
||||||
return Binary(b'\x19') #
|
return Binary(b'\x19') # EM
|
||||||
else:
|
else:
|
||||||
with self.fhapplk:
|
with self.fhapplk:
|
||||||
if self.fhapp is None or self.fhapp.closed:
|
if self.fhapp is None or self.fhapp.closed:
|
||||||
@@ -60,10 +70,17 @@ class LogReader:
|
|||||||
@return Binary() der Logdatei
|
@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):
|
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):
|
elif start > os.path.getsize(proginit.logplc):
|
||||||
return Binary(b'\x19') #
|
return Binary(b'\x19') # EM
|
||||||
else:
|
else:
|
||||||
with self.fhplclk:
|
with self.fhplclk:
|
||||||
if self.fhplc is None or self.fhplc.closed:
|
if self.fhplc is None or self.fhplc.closed:
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ from json import loads as jloads
|
|||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
from tempfile import mkstemp
|
from tempfile import mkstemp
|
||||||
from threading import Event
|
from threading import Event
|
||||||
from time import asctime
|
from time import asctime, time
|
||||||
from xmlrpc.client import Binary
|
from xmlrpc.client import Binary
|
||||||
|
|
||||||
import logsystem
|
import logsystem
|
||||||
@@ -876,10 +876,12 @@ class RevPiPyLoad:
|
|||||||
self.th_plcslave.start()
|
self.th_plcslave.start()
|
||||||
|
|
||||||
if self.xmlrpc and self.xsrv is not None:
|
if self.xmlrpc and self.xsrv is not None:
|
||||||
# Work xml calls in same thread or wait till timeout
|
# Work multiple xml calls in same thread until timeout
|
||||||
self.xsrv.handle_request()
|
xml_start = time()
|
||||||
|
while time() - xml_start < 1.0:
|
||||||
|
self.xsrv.handle_request()
|
||||||
else:
|
else:
|
||||||
self.evt_loadconfig.wait(1)
|
self.evt_loadconfig.wait(1.0)
|
||||||
|
|
||||||
proginit.logger.info("stopping revpipyload")
|
proginit.logger.info("stopping revpipyload")
|
||||||
|
|
||||||
|
|||||||
@@ -83,6 +83,8 @@ class SaveXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||||||
|
|
||||||
"""Verwaltet die XML-Requests und prueft Berechtigungen."""
|
"""Verwaltet die XML-Requests und prueft Berechtigungen."""
|
||||||
|
|
||||||
|
timeout = 2.0
|
||||||
|
|
||||||
def parse_request(self):
|
def parse_request(self):
|
||||||
"""Berechtigungen pruefen.
|
"""Berechtigungen pruefen.
|
||||||
@return True, wenn Parsen erfolgreich war"""
|
@return True, wenn Parsen erfolgreich war"""
|
||||||
|
|||||||
Reference in New Issue
Block a user