runtime/PLCObject.py
changeset 2459 21164625b393
parent 2429 15f18dc8b56a
parent 2443 75a274023970
child 2463 8742337a9fe3
--- a/runtime/PLCObject.py	Fri Nov 23 11:01:20 2018 +0100
+++ b/runtime/PLCObject.py	Fri Nov 23 12:13:24 2018 +0100
@@ -30,6 +30,10 @@
 import traceback
 from time import time
 import _ctypes  # pylint: disable=wrong-import-order
+from past.builtins import execfile
+import Pyro.core as pyro
+import six
+from six.moves import _thread, xrange
 
 from runtime.typemapping import TypeTranslator
 from runtime.loglevels import LogLevelsDefault, LogLevelsCount
@@ -95,12 +99,12 @@
                 self._GetMD5FileName(),
                 "r").read().strip() + lib_ext
             if self.LoadPLC():
-                self.PLCStatus = "Stopped"
+                self.PLCStatus = PlcStatus.Stopped
                 if autostart:
                     self.StartPLC()
                     return
         except Exception:
-            self.PLCStatus = "Empty"
+            self.PLCStatus = PlcStatus.Empty
             self.CurrentPLCFilename = None
 
         self.StatusChange()
@@ -466,7 +470,7 @@
             try:
                 if replace_PLC_shared_object:
                     os.remove(old_PLC_filename)
-                for filename in file(extra_files_log, "r").readlines() + [extra_files_log]:
+                for filename in open(extra_files_log, "rt").readlines() + [extra_files_log]:
                     try:
                         os.remove(os.path.join(self.workingdir, filename.strip()))
                     except Exception:
@@ -483,7 +487,7 @@
                 open(self._GetMD5FileName(), "w").write(md5sum)
 
                 # Then write the files
-                log = file(extra_files_log, "w")
+                log = open(extra_files_log, "w")
                 for fname, fdata in extrafiles:
                     fpath = os.path.join(self.workingdir, fname)
                     open(fpath, "wb").write(fdata)