Skip to content

Commit 352bcc4

Browse files
committed
[ModelicaSystem] improve handling of model simulation
* ensure a message if logged if returncode != 0
1 parent 9da5630 commit 352bcc4

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,15 +1185,15 @@ def simulate(
11851185
cmd_definition = om_cmd.definition()
11861186
returncode = self._session.run_model_executable(cmd_run_data=cmd_definition)
11871187
# and check returncode *AND* resultfile
1188-
if returncode != 0 and self._result_file.is_file():
1188+
if returncode != 0:
11891189
# check for an empty (=> 0B) result file which indicates a crash of the model executable
11901190
# see: https://github.com/OpenModelica/OMPython/issues/261
11911191
# https://github.com/OpenModelica/OpenModelica/issues/13829
1192-
if self._result_file.size() == 0:
1192+
if self._result_file.is_file() and self._result_file.size() == 0:
11931193
self._result_file.unlink()
11941194
raise ModelicaSystemError("Empty result file - this indicates a crash of the model executable!")
11951195

1196-
logger.warning(f"Return code = {returncode} but result file exists!")
1196+
logger.warning(f"Return code = {returncode} but result file was created!")
11971197

11981198
self._simulated = True
11991199

0 commit comments

Comments
 (0)