Added RepairPLC() to PLCObject. For now just calling PurgePLC and quit PLC runtime.
authorEdouard Tisserant
Tue, 16 Apr 2019 11:26:52 +0200
changeset 2596 779e8dbf1ee1
parent 2595 a0d2741a6722
child 2597 7e20fe7facd6
child 2599 b4649f014a39
Added RepairPLC() to PLCObject. For now just calling PurgePLC and quit PLC runtime.
ProjectController.py
runtime/PLCObject.py
--- a/ProjectController.py	Tue Apr 16 11:26:34 2019 +0200
+++ b/ProjectController.py	Tue Apr 16 11:26:52 2019 +0200
@@ -1924,7 +1924,7 @@
         answer = dialog.ShowModal()
         dialog.Destroy()
         if answer == wx.ID_YES:
-            self._connector.PurgePLC()
+            self._connector.RepairPLC()
 
     StatusMethods = [
         {
--- a/runtime/PLCObject.py	Tue Apr 16 11:26:34 2019 +0200
+++ b/runtime/PLCObject.py	Tue Apr 16 11:26:52 2019 +0200
@@ -533,6 +533,10 @@
     def _extra_files_log_path(self):
         return os.path.join(self.workingdir, "extra_files.txt")
 
+    def RepairPLC(self):
+        self.PurgePLC()
+        MainWorker.quit()
+
     @RunInMain
     def PurgePLC(self):
 
@@ -542,16 +546,19 @@
             if self.CurrentPLCFilename is not None \
             else None
 
+        allfiles = [extra_files_log, old_PLC_filename, self._GetMD5FileName()]
+
         try:
-            os.remove(old_PLC_filename)
-            for filename in open(extra_files_log, "rt").readlines() + [extra_files_log]:
-                try:
-                    os.remove(os.path.join(self.workingdir, filename.strip()))
-                except Exception:
-                    pass
+            allfiles.append(open(extra_files_log, "rt").readlines())
         except Exception:
             pass
 
+        for filename in allfiles:
+            try:
+                os.remove(os.path.join(self.workingdir, filename.strip()))
+            except Exception:
+                pass
+
         self.PLCStatus = PlcStatus.Empty
 
         # TODO: PLCObject restart