diff --git a/OMPython/ModelicaSystem.py b/OMPython/ModelicaSystem.py index 7ef2965e..67b51def 100644 --- a/OMPython/ModelicaSystem.py +++ b/OMPython/ModelicaSystem.py @@ -320,8 +320,9 @@ def _run_cmd(self, cmd: list): raise ModelicaSystemError(f"Error running command {cmd}: {stderr}") if self._verbose and stdout: logger.info("OM output for command %s:\n%s", cmd, stdout) - p.wait() - p.terminate() + # check process returncode, some errors don't print to stderr + if p.wait(): + raise ModelicaSystemError(f"Error running command {cmd}: nonzero returncode") except Exception as e: raise ModelicaSystemError(f"Exception {type(e)} running command {cmd}: {e}") @@ -736,7 +737,7 @@ def simulate(self, resultfile=None, simflags=None): # 11 raise Exception(f"Error: Application file path not found: {exe_file}") cmd = exe_file.as_posix() + override + csvinput + r + simflags - cmd = cmd.split(" ") + cmd = [s for s in cmd.split(' ') if s] self._run_cmd(cmd=cmd) self.simulationFlag = True @@ -1114,7 +1115,7 @@ def linearize(self, lintime: Optional[float] = None, simflags: Optional[str] = N raise Exception(f"Error: Application file path not found: {exe_file}") else: cmd = exe_file.as_posix() + linruntime + override + csvinput + simflags - cmd = cmd.split(' ') + cmd = [s for s in cmd.split(' ') if s] self._run_cmd(cmd=cmd) # code to get the matrix and linear inputs, outputs and states