Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions OMPython/ModelicaSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,25 @@ def getWorkDirectory(self) -> OMCPath:
"""
return self._work_dir

def check_model_executable(self):
"""
Check if the model executable is working
"""
# check if the executable exists ...
om_cmd = ModelExecutionCmd(
runpath=self.getWorkDirectory(),
cmd_local=self._session.model_execution_local,
cmd_windows=self._session.model_execution_windows,
cmd_prefix=self._session.model_execution_prefix(cwd=self.getWorkDirectory()),
model_name=self._model_name,
)
# ... by running it - output help for command help
om_cmd.arg_set(key="help", val="help")
cmd_definition = om_cmd.definition()
returncode = cmd_definition.run()
if returncode != 0:
raise ModelicaSystemError("Model executable not working!")

def buildModel(self, variableFilter: Optional[str] = None):
filter_def: Optional[str] = None
if variableFilter is not None:
Expand All @@ -591,19 +610,7 @@ def buildModel(self, variableFilter: Optional[str] = None):
logger.debug("OM model build result: %s", build_model_result)

# check if the executable exists ...
om_cmd = ModelExecutionCmd(
runpath=self.getWorkDirectory(),
cmd_local=self._session.model_execution_local,
cmd_windows=self._session.model_execution_windows,
cmd_prefix=self._session.model_execution_prefix(cwd=self.getWorkDirectory()),
model_name=self._model_name,
)
# ... by running it - output help for command help
om_cmd.arg_set(key="help", val="help")
cmd_definition = om_cmd.definition()
returncode = cmd_definition.run()
if returncode != 0:
raise ModelicaSystemError("Model executable not working!")
self.check_model_executable()

xml_file = self._session.omcpath(build_model_result[0]).parent / build_model_result[1]
self._xmlparse(xml_file=xml_file)
Expand Down
Loading