don't crash on trying to change IP interface for Beremiz_service using taskbar icon if IP wasn't previously
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Wed, 07 Dec 2016 18:23:59 +0300
changeset 1593 6a27490fed96
parent 1592 c40355f450a5
child 1594 049b7144a710
don't crash on trying to change IP interface for Beremiz_service using taskbar icon if IP wasn't previously


By default IP is not set (None) and service listen only on localhost interface.
Beremiz_service.py
--- a/Beremiz_service.py	Wed Dec 07 18:15:04 2016 +0300
+++ b/Beremiz_service.py	Wed Dec 07 18:23:59 2016 +0300
@@ -286,7 +286,9 @@
                         print _("PLC is not started.")
 
             def OnTaskBarChangeInterface(self, evt):
-                dlg = ParamsEntryDialog(None, _("Enter the IP of the interface to bind"), defaultValue=self.pyroserver.ip_addr)
+                ip_addr = self.pyroserver.ip_addr
+                ip_addr = '' if ip_addr is None else ip_addr
+                dlg = ParamsEntryDialog(None, _("Enter the IP of the interface to bind"), defaultValue=ip_addr)                
                 dlg.SetTests([(re.compile('\d{1,3}(?:\.\d{1,3}){3}$').match, _("IP is not valid!")),
                                ( lambda x :len([x for x in x.split(".") if 0 <= int(x) <= 255]) == 4, _("IP is not valid!"))
                                ])