Skip to content

Commit 5b21a06

Browse files
authored
Fix two spaces in simflags causing silent error (#264)
1 parent cb657cf commit 5b21a06

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

OMPython/ModelicaSystem.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,9 @@ def _run_cmd(self, cmd: list):
320320
raise ModelicaSystemError(f"Error running command {cmd}: {stderr}")
321321
if self._verbose and stdout:
322322
logger.info("OM output for command %s:\n%s", cmd, stdout)
323-
p.wait()
324-
p.terminate()
323+
# check process returncode, some errors don't print to stderr
324+
if p.wait():
325+
raise ModelicaSystemError(f"Error running command {cmd}: nonzero returncode")
325326
except Exception as e:
326327
raise ModelicaSystemError(f"Exception {type(e)} running command {cmd}: {e}")
327328

@@ -736,7 +737,7 @@ def simulate(self, resultfile=None, simflags=None): # 11
736737
raise Exception(f"Error: Application file path not found: {exe_file}")
737738

738739
cmd = exe_file.as_posix() + override + csvinput + r + simflags
739-
cmd = cmd.split(" ")
740+
cmd = [s for s in cmd.split(' ') if s]
740741
self._run_cmd(cmd=cmd)
741742
self.simulationFlag = True
742743

@@ -1114,7 +1115,7 @@ def linearize(self, lintime: Optional[float] = None, simflags: Optional[str] = N
11141115
raise Exception(f"Error: Application file path not found: {exe_file}")
11151116
else:
11161117
cmd = exe_file.as_posix() + linruntime + override + csvinput + simflags
1117-
cmd = cmd.split(' ')
1118+
cmd = [s for s in cmd.split(' ') if s]
11181119
self._run_cmd(cmd=cmd)
11191120

11201121
# code to get the matrix and linear inputs, outputs and states

0 commit comments

Comments
 (0)