Removed harmful assert in ProcessLogger. svghmi
authorEdouard Tisserant
Wed, 13 Jan 2021 10:28:09 +0100
branchsvghmi
changeset 3109 6c39d718e8cb
parent 3107 ee0704cc6dc8
child 3110 476bd870313d
Removed harmful assert in ProcessLogger.

ProcessLogger was having an assert in constructor when missing logger, leading to systematic exception when testing options accepted by compiler. This exception was silenced in ProjectController, and then MatIEC was always called without options.
ProjectController.py
util/ProcessLogger.py
--- a/ProjectController.py	Tue Jan 05 01:23:45 2021 +0100
+++ b/ProjectController.py	Wed Jan 13 10:28:09 2021 +0100
@@ -159,6 +159,7 @@
                                                          no_stdout=True,
                                                          no_stderr=True).spin()
         except Exception:
+            self.logger.write_error(_("Couldn't launch IEC compiler to determine compatible options.\n"))
             return buildopt
 
         for opt in options:
--- a/util/ProcessLogger.py	Tue Jan 05 01:23:45 2021 +0100
+++ b/util/ProcessLogger.py	Wed Jan 13 10:28:09 2021 +0100
@@ -78,7 +78,6 @@
                  timeout=None, outlimit=None, errlimit=None,
                  endlog=None, keyword=None, kill_it=False, cwd=None,
                  encoding=None, output_encoding=None):
-        assert(logger)
         self.logger = logger
         if not isinstance(Command, list):
             self.Command_str = Command
@@ -160,7 +159,7 @@
             v = v.decode(self.output_encoding)
         self.outdata.append(v)
         self.outlen += 1
-        if not self.no_stdout:
+        if self.logger and not self.no_stdout:
             self.logger.write(v)
         if (self.keyword and v.find(self.keyword) != -1) or (self.outlimit and self.outlen > self.outlimit):
             self.endlog()
@@ -170,7 +169,7 @@
             v = v.decode(self.output_encoding)
         self.errdata.append(v)
         self.errlen += 1
-        if not self.no_stderr:
+        if self.logger and not self.no_stderr:
             self.logger.write_warning(v)
         if self.errlimit and self.errlen > self.errlimit:
             self.endlog()