Skip to content

Commit 1104c06

Browse files
committed
[ModelicaSystem.buildModel] check if executable exists via ModelicaSystemCmd
1 parent e977ee6 commit 1104c06

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

OMPython/ModelicaSystem.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,20 @@ def buildModel(self, variableFilter: Optional[str] = None):
514514
buildModelResult = self._requestApi(apiName="buildModel", entity=self._model_name, properties=var_filter)
515515
logger.debug("OM model build result: %s", buildModelResult)
516516

517+
# check if the executable exists ...
518+
om_cmd = ModelicaSystemCmd(
519+
session=self._getconn,
520+
runpath=self.getWorkDirectory(),
521+
modelname=self._model_name,
522+
timeout=5.0,
523+
)
524+
# ... by running it - output help for command help
525+
om_cmd.arg_set(key="help", val="help")
526+
cmd_definition = om_cmd.definition()
527+
returncode = self._getconn.run_model_executable(cmd_run_data=cmd_definition)
528+
if returncode != 0:
529+
raise ModelicaSystemError("Model executable not working!")
530+
517531
xml_file = self._getconn.omcpath(buildModelResult[0]).parent / buildModelResult[1]
518532
self._xmlparse(xml_file=xml_file)
519533

0 commit comments

Comments
 (0)