--- a/Beremiz_service.py Mon Dec 09 14:53:42 2019 +0100
+++ b/Beremiz_service.py Wed Dec 18 13:31:22 2019 +0100
@@ -30,6 +30,7 @@
from threading import Thread, Semaphore, Lock, currentThread
from builtins import str as text
from past.builtins import execfile
@@ -44,6 +45,10 @@
from runtime.Stunnel import ensurePSK
import util.paths as paths
+ from runtime.spawn_subprocess import Popen + from subprocess import Popen from version import app_version
@@ -72,7 +77,7 @@
- opts, argv = getopt.getopt(sys.argv[1:], "i:p:n:x:t:a:w:c:e:s:h", ["help", "version"])
+ opts, argv = getopt.getopt(sys.argv[1:], "i:p:n:x:t:a:w:c:e:s:h", ["help", "version", "status-change=", "on-plc-start=", "on-plc-stop="]) except getopt.GetoptError as err:
# print help information and exit:
print(str(err)) # will print something like "option -a not recognized"
@@ -93,6 +98,13 @@
+def status_change_call_factory(wanted, args): + def status_change_call(status): + if wanted is None or status is wanted: + cmd = shlex.split(args.format(status)) + return status_change_call if o == "-h" or o == "--help":
@@ -101,6 +113,12 @@
+ if o == "--on-plc-start": + statuschange.append(status_change_call_factory(PlcStatus.Started, a)) + elif o == "--on-plc-stop": + statuschange.append(status_change_call_factory(PlcStatus.Stopped, a)) + elif o == "--status-change": + statuschange.append(status_change_call_factory(None, a)) if len(a.split(".")) == 4:
@@ -401,7 +419,6 @@