Fixed non-wx runtime python evaluation stuff.
authoretisserant
Fri, 06 Mar 2009 21:42:57 +0100
changeset 319 bdd82ac65f5d
parent 318 b24790c748ae
child 320 76492675c3ed
Fixed non-wx runtime python evaluation stuff.
Beremiz_service.py
runtime/PLCObject.py
--- a/Beremiz_service.py	Mon Mar 02 09:23:34 2009 +0100
+++ b/Beremiz_service.py	Fri Mar 06 21:42:57 2009 +0100
@@ -368,8 +368,11 @@
 if not os.path.isdir(WorkingDir):
     os.mkdir(WorkingDir)
 
+def default_evaluator(callable, *args, **kwargs):
+    return callable(*args,**kwargs)
+
 class Server():
-    def __init__(self, name, ip, port, workdir, argv, statuschange=None, evaluator=eval):
+    def __init__(self, name, ip, port, workdir, argv, statuschange=None, evaluator=default_evaluator):
         self.continueloop = True
         self.daemon = None
         self.name = name
--- a/runtime/PLCObject.py	Mon Mar 02 09:23:34 2009 +0100
+++ b/runtime/PLCObject.py	Fri Mar 06 21:42:57 2009 +0100
@@ -193,28 +193,29 @@
                    execfile(hmifile, self.python_threads_vars)
                 execfile(pyfile, self.python_threads_vars)
                 try:
-                   wx = self.python_threads_vars['wx']
-                   # try to instanciate the first frame found.
-                   for name, obj in self.python_threads_vars.iteritems():
-                       # obj is a class
-                       if type(obj)==type(type) and issubclass(obj,wx.Frame):
-                           def create_frame():
-                               self.hmi_frame = obj(None)
-                               self.python_threads_vars[name] = self.hmi_frame
-                               # keep track of class... never know
-                               self.python_threads_vars['Class_'+name] = obj
-                               self.hmi_frame.Bind(wx.EVT_CLOSE, OnCloseFrame)
-                               self.hmi_frame.Show()
-                           
-                           def OnCloseFrame(evt):
-                               self.hmi_frame.Destroy()
-                               self.hmi_frame = None
-                               wx.MessageBox("Please stop PLC to close")
-                               #wx.CallAfter(self.StopPLC)
-                               create_frame()
-                               #evt.Skip()
-                           create_frame()
-                           break
+                   if self.python_threads_vars.has_key('wx'):
+	                   wx = self.python_threads_vars['wx']
+	                   # try to instanciate the first frame found.
+	                   for name, obj in self.python_threads_vars.iteritems():
+	                       # obj is a class
+	                       if type(obj)==type(type) and issubclass(obj,wx.Frame):
+	                           def create_frame():
+	                               self.hmi_frame = obj(None)
+	                               self.python_threads_vars[name] = self.hmi_frame
+	                               # keep track of class... never know
+	                               self.python_threads_vars['Class_'+name] = obj
+	                               self.hmi_frame.Bind(wx.EVT_CLOSE, OnCloseFrame)
+	                               self.hmi_frame.Show()
+	                           
+	                           def OnCloseFrame(evt):
+	                               self.hmi_frame.Destroy()
+	                               self.hmi_frame = None
+	                               wx.MessageBox("Please stop PLC to close")
+	                               #wx.CallAfter(self.StopPLC)
+	                               create_frame()
+	                               #evt.Skip()
+	                           create_frame()
+	                           break
                 except:
                     PLCprint(traceback.format_exc())
             except: