Skip to content

Commit 9dc12bf

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 299b3aa commit 9dc12bf

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
@@ -801,20 +801,23 @@ def run_model_executable(cmd_run_data: OMCSessionRunData) -> int:
801801
env=my_env,
802802
cwd=cmd_run_data.cmd_cwd_local,
803803
timeout=cmd_run_data.cmd_timeout,
804-
check=True,
804+
check=False,
805805
)
806806
stdout = cmdres.stdout.strip()
807807
stderr = cmdres.stderr.strip()
808808
returncode = cmdres.returncode
809809

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

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

819822
return returncode
820823

0 commit comments

Comments
 (0)