diff -r 191a568a2a17 -r 4f0e1d66bba5 runtime/PLCObject.py --- a/runtime/PLCObject.py Tue Mar 31 09:38:44 2009 +0200 +++ b/runtime/PLCObject.py Sat Apr 04 10:43:29 2009 +0200 @@ -26,7 +26,6 @@ from threading import Timer, Thread import ctypes, os, commands, types, sys - if os.name in ("nt", "ce"): from _ctypes import LoadLibrary as dlopen from _ctypes import FreeLibrary as dlclose @@ -183,17 +182,17 @@ self.python_threads_vars = globals().copy() pyfile = os.path.join(self.workingdir, "runtime.py") hmifile = os.path.join(self.workingdir, "hmi.py") - if os.path.exists(pyfile): - try: - # TODO handle exceptions in runtime.py - # pyfile may redefine _runtime_cleanup - # or even call _PythonThreadProc itself. - execfile(pyfile, self.python_threads_vars) - except: - PLCprint(traceback.format_exc()) if os.path.exists(hmifile): try: execfile(hmifile, self.python_threads_vars) + if os.path.exists(pyfile): + try: + # TODO handle exceptions in runtime.py + # pyfile may redefine _runtime_cleanup + # or even call _PythonThreadProc itself. + execfile(pyfile, self.python_threads_vars) + except: + PLCprint(traceback.format_exc()) if self.python_threads_vars.has_key('wx'): wx = self.python_threads_vars['wx'] # try to instanciate the first frame found. @@ -214,6 +213,14 @@ break except: PLCprint(traceback.format_exc()) + elif os.path.exists(pyfile): + try: + # TODO handle exceptions in runtime.py + # pyfile may redefine _runtime_cleanup + # or even call _PythonThreadProc itself. + execfile(pyfile, self.python_threads_vars) + except: + PLCprint(traceback.format_exc()) runtime_begin = self.python_threads_vars.get("_runtime_begin",None) if runtime_begin is not None: runtime_begin()