Removed harmful assert in ProcessLogger.
authorEdouard Tisserant
Wed, 13 Jan 2021 10:28:09 +0100
changeset 2712 a00f41d097f3
parent 2711 ecfb59e4ecb0
child 2719 745b64e7c695
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 Dec 22 18:05:05 2020 +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 Dec 22 18:05:05 2020 +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()