Skip to content

Commit 1d55f4e

Browse files
committed
[ModelicaSystem.buildModel] check if executable exists via ModelicaSystemCmd
1 parent 4331df1 commit 1d55f4e

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
@@ -518,6 +518,20 @@ def buildModel(self, variableFilter: Optional[str] = None):
518518
buildModelResult = self._requestApi(apiName="buildModel", entity=self._model_name, properties=var_filter)
519519
logger.debug("OM model build result: %s", buildModelResult)
520520

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

0 commit comments

Comments
 (0)