Skip to content

Commit 45946c5

Browse files
committed
[ModelicaSystem.buildModel] check if executable exists via ModelicaSystemCmd
1 parent d7b7354 commit 45946c5

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

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

0 commit comments

Comments
 (0)