Skip to content

Commit 7298ac9

Browse files
committed
[ModelicaSystem] improve handling of model simulation
* ensure a message if logged if returncode != 0
1 parent a32dac8 commit 7298ac9

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
@@ -1168,15 +1168,15 @@ def simulate(
11681168
cmd_definition = om_cmd.definition()
11691169
returncode = self._session.run_model_executable(cmd_run_data=cmd_definition)
11701170
# and check returncode *AND* resultfile
1171-
if returncode != 0 and self._result_file.is_file():
1171+
if returncode != 0:
11721172
# check for an empty (=> 0B) result file which indicates a crash of the model executable
11731173
# see: https://github.com/OpenModelica/OMPython/issues/261
11741174
# https://github.com/OpenModelica/OpenModelica/issues/13829
1175-
if self._result_file.size() == 0:
1175+
if self._result_file.is_file() and self._result_file.size() == 0:
11761176
self._result_file.unlink()
11771177
raise ModelicaSystemError("Empty result file - this indicates a crash of the model executable!")
11781178

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

11811181
self._simulated = True
11821182

0 commit comments

Comments
 (0)