Skip to content

Commit 3862b41

Browse files
committed
[ModelicaSystem.buildModel] check if executable exists via ModelicaSystemCmd
1 parent e1f9e9a commit 3862b41

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,20 @@ def buildModel(self, variableFilter: Optional[str] = None):
444444
buildModelResult = self._requestApi("buildModel", self._model_name, properties=varFilter)
445445
logger.debug("OM model build result: %s", buildModelResult)
446446

447+
# check if the executable exists ...
448+
om_cmd = ModelicaSystemCmd(
449+
session=self._getconn,
450+
runpath=self.getWorkDirectory(),
451+
modelname=self._model_name,
452+
timeout=5.0,
453+
)
454+
# ... and outputs help for command help
455+
om_cmd.arg_set(key="help", val="help")
456+
cmd_definition = om_cmd.definition()
457+
returncode = self._getconn.run_model_executable(cmd_run_data=cmd_definition)
458+
if returncode != 0:
459+
raise ModelicaSystemError("Error on model executable test!")
460+
447461
xml_file = self._getconn.omcpath(buildModelResult[0]).parent / buildModelResult[1]
448462
self._xmlparse(xml_file=xml_file)
449463

0 commit comments

Comments
 (0)