mirror of
https://github.com/naruxde/revpipyload.git
synced 2025-11-08 23:23:52 +01:00
New XML functions for RevPiCommander
This commit is contained in:
11
debian/postinst
vendored
11
debian/postinst
vendored
@@ -6,6 +6,17 @@ PATH=/bin:/sbin:/usr/bin:/usr/sbin
|
|||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
configure)
|
configure)
|
||||||
|
cat <<-END
|
||||||
|
|
||||||
|
========== Important RevPiPyLoad post-installation note ==========
|
||||||
|
|
||||||
|
The XML-RPC service is bind to localhost, only. To access the
|
||||||
|
daemon via RevPiCommander from your network, please change the
|
||||||
|
bindip in /etc/revpipyload/revpipyload.conf or execute:
|
||||||
|
|
||||||
|
sudo revpipyload_secure_installation
|
||||||
|
|
||||||
|
END
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|||||||
@@ -484,6 +484,10 @@ class RevPiPyLoad:
|
|||||||
3, self.xml_plcslavestart, "plcslavestart")
|
3, self.xml_plcslavestart, "plcslavestart")
|
||||||
self.xsrv.register_function(
|
self.xsrv.register_function(
|
||||||
3, self.xml_plcslavestop, "plcslavestop")
|
3, self.xml_plcslavestop, "plcslavestop")
|
||||||
|
self.xsrv.register_function(
|
||||||
|
3, self.xml_plcdelete_file, "plcdeletefile")
|
||||||
|
self.xsrv.register_function(
|
||||||
|
3, self.xml_plcdownload_file, "plcdownload_file")
|
||||||
|
|
||||||
# XML Modus 4 Einstellungen ändern
|
# XML Modus 4 Einstellungen ändern
|
||||||
self.xsrv.register_function(
|
self.xsrv.register_function(
|
||||||
@@ -872,7 +876,7 @@ 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:
|
||||||
# Wort xml calls in same thread or wait till timeout
|
# Work xml calls in same thread or wait till timeout
|
||||||
self.xsrv.handle_request()
|
self.xsrv.handle_request()
|
||||||
else:
|
else:
|
||||||
self.evt_loadconfig.wait(1)
|
self.evt_loadconfig.wait(1)
|
||||||
@@ -1062,6 +1066,24 @@ class RevPiPyLoad:
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def xml_plcdelete_file(self, file_name: str):
|
||||||
|
"""
|
||||||
|
Delete a single file in work directory.
|
||||||
|
|
||||||
|
:param file_name: File with full path relative to work directory
|
||||||
|
:return: True on success
|
||||||
|
"""
|
||||||
|
file_name = os.path.join(self.plcworkdir, file_name)
|
||||||
|
if os.path.exists(file_name):
|
||||||
|
os.remove(file_name)
|
||||||
|
try:
|
||||||
|
# Try to remove directory if empty
|
||||||
|
os.rmdir(os.path.dirname(file_name))
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def xml_plcdownload(self, mode="tar", pictory=False):
|
def xml_plcdownload(self, mode="tar", pictory=False):
|
||||||
"""Uebertraegt ein Archiv vom plcworkdir.
|
"""Uebertraegt ein Archiv vom plcworkdir.
|
||||||
|
|
||||||
@@ -1082,6 +1104,20 @@ class RevPiPyLoad:
|
|||||||
return xmldata
|
return xmldata
|
||||||
return Binary()
|
return Binary()
|
||||||
|
|
||||||
|
def xml_plcdownload_file(self, file_name:str):
|
||||||
|
"""
|
||||||
|
Download a single file from work directory.
|
||||||
|
|
||||||
|
:param file_name: File with full path relative to work directory
|
||||||
|
:return: Binary object in gzip format
|
||||||
|
"""
|
||||||
|
file_name = os.path.join(self.plcworkdir, file_name)
|
||||||
|
if os.path.exists(file_name):
|
||||||
|
with open(file_name, "rb") as fh:
|
||||||
|
xmldata = Binary(gzip.compress(fh.read()))
|
||||||
|
return xmldata
|
||||||
|
return Binary()
|
||||||
|
|
||||||
def xml_plcexitcode(self):
|
def xml_plcexitcode(self):
|
||||||
"""Gibt den aktuellen exitcode vom PLC Programm zurueck.
|
"""Gibt den aktuellen exitcode vom PLC Programm zurueck.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user