--- a/Beremiz_service.py Sun Nov 20 18:14:04 2011 +0100
+++ b/Beremiz_service.py Mon Nov 21 11:40:29 2011 +0100
@@ -27,9 +27,9 @@
Usage of Beremiz PLC execution service :\n
-%s {[-n servicename] [-i ip] [-p port] [-x enabletaskbar] [-a autostart]|-h|--help} working_dir
+%s {[-n servicename] [-i IP] [-p port] [-x enabletaskbar] [-a autostart]|-h|--help} working_dir -n - zeroconf service name (default:disabled)
- -i - ip of interface to bind to (default:localhost)
+ -i - IP address of interface to bind to (default:localhost) -p - port number default:3000
-h - print this help text and quit
-a - autostart PLC (0:disable 1:enable) (default:0)
@@ -48,7 +48,7 @@
@@ -63,7 +63,10 @@
if len(a.split(".")) == 4 or a == "localhost":
# port: port that the service runs on
@@ -349,12 +352,12 @@
def OnTaskBarChangeInterface(self, evt):
- dlg = ParamsEntryDialog(None, _("Enter the IP of the interface to bind"), defaultValue=self.pyroserver.ip)
+ dlg = ParamsEntryDialog(None, _("Enter the IP of the interface to bind"), defaultValue=self.pyroserver.ip_addr) dlg.SetTests([(re.compile('\d{1,3}(?:\.\d{1,3}){3}$').match, _("IP is not valid!")),
- ( lambda ip :len([x for x in ip.split(".") if 0 <= int(x) <= 255]) == 4, _("IP is not valid!"))
+ ( lambda x :len([x for x in x.split(".") if 0 <= int(x) <= 255]) == 4, _("IP is not valid!")) if dlg.ShowModal() == wx.ID_OK:
- self.pyroserver.ip = dlg.GetValue()
+ self.pyroserver.ip_addr = dlg.GetValue() @@ -430,11 +433,11 @@
return callable(*args,**kwargs)
- def __init__(self, servicename, ip, port, workdir, argv, autostart=False, statuschange=None, evaluator=default_evaluator, website=None):
+ def __init__(self, servicename, ip_addr, port, workdir, argv, autostart=False, statuschange=None, evaluator=default_evaluator, website=None): self.servicename = servicename
@@ -458,7 +461,7 @@
- self.daemon=pyro.Daemon(host=self.ip, port=self.port)
+ self.daemon=pyro.Daemon(host=self.ip_addr, port=self.port) self.plcobj = PLCObject(self.workdir, self.daemon, self.argv, self.statuschange, self.evaluator, self.website)
uri = self.daemon.connect(self.plcobj,"PLCObject")
@@ -468,10 +471,10 @@
# Configure and publish service
# Not publish service if localhost in address params
- if self.servicename is not None and self.ip != "localhost" and self.ip != "127.0.0.1":
+ if self.servicename is not None and self.ip_addr != "localhost" and self.ip_addr != "127.0.0.1": print "Publishing service on local network"
self.servicepublisher = ServicePublisher.ServicePublisher()
- self.servicepublisher.RegisterService(self.servicename, self.ip, self.port)
+ self.servicepublisher.RegisterService(self.servicename, self.ip_addr, self.port) @@ -694,10 +697,10 @@
- pyroserver = Server(servicename, ip, port, WorkingDir, argv, autostart, statuschange, evaluator, website)
+ pyroserver = Server(servicename, given_ip, port, WorkingDir, argv, autostart, statuschange, evaluator, website) taskbar_instance = BeremizTaskBarIcon(pyroserver)
- pyroserver = Server(servicename, ip, port, WorkingDir, argv, autostart, website=website)
+ pyroserver = Server(servicename, given_ip, port, WorkingDir, argv, autostart, website=website) if havetwisted or havewx:
pyro_thread=Thread(target=pyroserver.Loop)
--- a/Zeroconf.py Sun Nov 20 18:14:04 2011 +0100
+++ b/Zeroconf.py Mon Nov 21 11:40:29 2011 +0100
@@ -861,7 +861,8 @@
self.readers[socket].handle_read()
+ # Ignore errors that occur on shutdown --- a/discovery.py Sun Nov 20 18:14:04 2011 +0100
+++ b/discovery.py Mon Nov 21 11:40:29 2011 +0100
@@ -174,6 +174,10 @@
def removeService(self, zeroconf, type, name):
+ wx.CallAfter(self._removeService, name) + def _removeService(self, name): called when a service with the desired type goes offline.
@@ -191,6 +195,9 @@
def addService(self, zeroconf, type, name):
+ wx.CallAfter(self._addService, type, name) + def _addService(self, type, name): called when a service with the desired type is discovered.
@@ -222,4 +229,4 @@
self.itemDataMap[self.nextItemId] = [ svcname, typename, ip, port, name ]
\ No newline at end of file