531 shutil.move(path, newpath) |
531 shutil.move(path, newpath) |
532 |
532 |
533 def _extra_files_log_path(self): |
533 def _extra_files_log_path(self): |
534 return os.path.join(self.workingdir, "extra_files.txt") |
534 return os.path.join(self.workingdir, "extra_files.txt") |
535 |
535 |
|
536 def RepairPLC(self): |
|
537 self.PurgePLC() |
|
538 MainWorker.quit() |
|
539 |
536 @RunInMain |
540 @RunInMain |
537 def PurgePLC(self): |
541 def PurgePLC(self): |
538 |
542 |
539 extra_files_log = self._extra_files_log_path() |
543 extra_files_log = self._extra_files_log_path() |
540 |
544 |
541 old_PLC_filename = os.path.join(self.workingdir, self.CurrentPLCFilename) \ |
545 old_PLC_filename = os.path.join(self.workingdir, self.CurrentPLCFilename) \ |
542 if self.CurrentPLCFilename is not None \ |
546 if self.CurrentPLCFilename is not None \ |
543 else None |
547 else None |
544 |
548 |
|
549 allfiles = [extra_files_log, old_PLC_filename, self._GetMD5FileName()] |
|
550 |
545 try: |
551 try: |
546 os.remove(old_PLC_filename) |
552 allfiles.append(open(extra_files_log, "rt").readlines()) |
547 for filename in open(extra_files_log, "rt").readlines() + [extra_files_log]: |
|
548 try: |
|
549 os.remove(os.path.join(self.workingdir, filename.strip())) |
|
550 except Exception: |
|
551 pass |
|
552 except Exception: |
553 except Exception: |
553 pass |
554 pass |
|
555 |
|
556 for filename in allfiles: |
|
557 try: |
|
558 os.remove(os.path.join(self.workingdir, filename.strip())) |
|
559 except Exception: |
|
560 pass |
554 |
561 |
555 self.PLCStatus = PlcStatus.Empty |
562 self.PLCStatus = PlcStatus.Empty |
556 |
563 |
557 # TODO: PLCObject restart |
564 # TODO: PLCObject restart |
558 |
565 |