Skip to content

Commit eea4a5d

Browse files
committed
[ModelicaSystem.buildModel] check if executable exists via ModelicaSystemCmd
1 parent 6b50282 commit eea4a5d

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
@@ -449,6 +449,20 @@ def buildModel(self, variableFilter: Optional[str] = None):
449449
buildModelResult = self._requestApi("buildModel", self._model_name, properties=varFilter)
450450
logger.debug("OM model build result: %s", buildModelResult)
451451

452+
# check if the executable exists ...
453+
om_cmd = ModelicaSystemCmd(
454+
session=self._getconn,
455+
runpath=self.getWorkDirectory(),
456+
modelname=self._model_name,
457+
timeout=5.0,
458+
)
459+
# ... by running it - output help for command help
460+
om_cmd.arg_set(key="help", val="help")
461+
cmd_definition = om_cmd.definition()
462+
returncode = self._getconn.run_model_executable(cmd_run_data=cmd_definition)
463+
if returncode != 0:
464+
raise ModelicaSystemError("Model executable not working!")
465+
452466
xml_file = self._getconn.omcpath(buildModelResult[0]).parent / buildModelResult[1]
453467
self._xmlparse(xml_file=xml_file)
454468

0 commit comments

Comments
 (0)