Extended exception info from evaluator. Problems in python runtime init/cleanup code now more readable
authorEdouard Tisserant
Wed, 24 Apr 2013 15:44:46 +0900
changeset 1051 847d68c3e7ff
parent 1050 56bef276055e
child 1052 fa7c5034c1d2
Extended exception info from evaluator. Problems in python runtime init/cleanup code now more readable
Beremiz_service.py
runtime/PLCObject.py
--- a/Beremiz_service.py	Wed Apr 24 12:24:12 2013 +0900
+++ b/Beremiz_service.py	Wed Apr 24 15:44:46 2013 +0900
@@ -425,8 +425,8 @@
 def default_evaluator(tocall, *args, **kwargs):
     try:
         res=(tocall(*args,**kwargs), None)
-    except Exception,exp:
-        res=(None, exp)
+    except Exception:
+        res=(None, sys.exc_info())
     return res
 
 class Server():
--- a/runtime/PLCObject.py	Wed Apr 24 12:24:12 2013 +0900
+++ b/runtime/PLCObject.py	Wed Apr 24 15:44:46 2013 +0900
@@ -243,13 +243,10 @@
         Calls init, start, stop or cleanup method provided by 
         runtime python files, loaded when new PLC uploaded
         """
-        try :
-            for method in self.python_runtime_vars.get("_runtime_%s"%methodname, []):
-                res,exp = self.evaluator(method)
-                if exp is not None: raise(exp)
-        except:
-            self.LogMessage(0,traceback.format_exc())
-            raise
+        for method in self.python_runtime_vars.get("_runtime_%s"%methodname, []):
+            res,exp = self.evaluator(method)
+            if exp is not None: 
+                self.LogMessage(0,traceback.format_exception(*exp))
 
     def PythonRuntimeInit(self):
         MethodNames = ["init", "start", "stop", "cleanup"]
@@ -312,7 +309,7 @@
                     compile_cache[FBID]=(cmd,AST)
                 result,exp = self.evaluator(eval,cmd,self.python_runtime_vars)
                 if exp is not None: 
-                    raise(exp)
+                    raise(exp[1])
                 else:
                     res=str(result)
                 self.python_runtime_vars["FBID"]=None