Skip to content

Commit a32dac8

Browse files
committed
[OMCSession] improve log messages for model simulation using OM executable
* use check=False => no CalledProcessError exception; possibility to handle the error code * error code needs to be checked (compare == 0) by the caller! * improve log messages; print returncode if it is != 0 with stdout
1 parent 76b73e5 commit a32dac8

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

OMPython/OMCSession.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -800,20 +800,23 @@ def run_model_executable(cmd_run_data: OMCSessionRunData) -> int:
800800
env=my_env,
801801
cwd=cmd_run_data.cmd_cwd_local,
802802
timeout=cmd_run_data.cmd_timeout,
803-
check=True,
803+
check=False,
804804
)
805805
stdout = cmdres.stdout.strip()
806806
stderr = cmdres.stderr.strip()
807807
returncode = cmdres.returncode
808808

809-
logger.debug("OM output for command %s:\n%s", repr(cmdl), stdout)
809+
if returncode != 0:
810+
logger.warning("OM executable run %s with returncode=%d and stdout:\n%s",
811+
repr(cmdl), returncode, stdout)
812+
else:
813+
logger.debug("OM executable run %s with stdout:\n%s", repr(cmdl), stdout)
810814

811815
if stderr:
812816
raise OMCSessionException(f"Error running model executable {repr(cmdl)}: {stderr}")
817+
813818
except subprocess.TimeoutExpired as ex:
814819
raise OMCSessionException(f"Timeout running model executable {repr(cmdl)}") from ex
815-
except subprocess.CalledProcessError as ex:
816-
raise OMCSessionException(f"Error running model executable {repr(cmdl)}") from ex
817820

818821
return returncode
819822

0 commit comments

Comments
 (0)