Catch Pyro exception when connection closed and print message
authorlaurent
Wed, 09 Dec 2009 09:44:17 +0100
changeset 486 2e0fe44044b3
parent 485 8b2da4b9d408
child 487 1df4a28d3586
Catch Pyro exception when connection closed and print message
connectors/PYRO/__init__.py
plugger.py
--- a/connectors/PYRO/__init__.py	Wed Dec 09 09:43:21 2009 +0100
+++ b/connectors/PYRO/__init__.py	Wed Dec 09 09:44:17 2009 +0100
@@ -56,6 +56,9 @@
         def catcher_func(*args,**kwargs):
             try:
                 return func(*args,**kwargs)
+            except Pyro.errors.ConnectionClosedError, e:
+                pluginsroot.logger.write_error("Connection lost!\n")
+                pluginsroot._connector = None
             except Exception,e:
                 #pluginsroot.logger.write_error(traceback.format_exc())
                 errmess = ''.join(Pyro.util.getPyroTraceback(e))
--- a/plugger.py	Wed Dec 09 09:43:21 2009 +0100
+++ b/plugger.py	Wed Dec 09 09:44:17 2009 +0100
@@ -1540,9 +1540,10 @@
     def UpdateMethodsFromPLCStatus(self):
         # Get PLC state : Running or Stopped
         # TODO : use explicit status instead of boolean
+        status = None
         if self._connector is not None:
             status = self._connector.GetPLCstatus()
-        else:
+        if status is None:
             status = "Disconnected"
         if(self.previous_plcstate != status):
             for args in {
@@ -1568,6 +1569,7 @@
         if self._connector is None:
             self.StatusTimer.Stop()
         if self.UpdateMethodsFromPLCStatus():
+            
             status = _(self.previous_plcstate)
             {"Broken": self.logger.write_error,
              None: lambda x: None}.get(