Skip to content

Commit 50f9a91

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 9da5630 commit 50f9a91

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
@@ -830,20 +830,23 @@ def run_model_executable(self, cmd_run_data: OMCSessionRunData) -> int:
830830
env=my_env,
831831
cwd=cmd_run_data.cmd_cwd_local,
832832
timeout=self._timeout,
833-
check=True,
833+
check=False,
834834
)
835835
stdout = cmdres.stdout.strip()
836836
stderr = cmdres.stderr.strip()
837837
returncode = cmdres.returncode
838838

839-
logger.debug("OM output for command %s:\n%s", repr(cmdl), stdout)
839+
if returncode != 0:
840+
logger.warning("OM executable run %s with returncode=%d and stdout:\n%s",
841+
repr(cmdl), returncode, stdout)
842+
else:
843+
logger.debug("OM executable run %s with stdout:\n%s", repr(cmdl), stdout)
840844

841845
if stderr:
842846
raise OMCSessionException(f"Error running model executable {repr(cmdl)}: {stderr}")
847+
843848
except subprocess.TimeoutExpired as ex:
844849
raise OMCSessionException(f"Timeout running model executable {repr(cmdl)}") from ex
845-
except subprocess.CalledProcessError as ex:
846-
raise OMCSessionException(f"Error running model executable {repr(cmdl)}") from ex
847850

848851
return returncode
849852

0 commit comments

Comments
 (0)