Skip to content

Commit 4cc509d

Browse files
committed
[ModelicaSystemCmd] simplify
1 parent fbca54d commit 4cc509d

File tree

1 file changed

+9
-24
lines changed

1 file changed

+9
-24
lines changed

OMPython/ModelicaSystem.py

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,6 @@ def __init__(self, runpath: pathlib.Path, modelname: str, timeout: Optional[int]
128128
self._timeout = timeout
129129
self._args = {}
130130

131-
self._exe_file = self.get_exe_file(tempdir=runpath, modelname=modelname)
132-
if not self._exe_file.exists():
133-
raise ModelicaSystemError(f"Application file path not found: {self._exe_file}")
134-
135131
def arg_set(self, key: str, val: str = None) -> None:
136132
"""
137133
Set one argument for the executeable model.
@@ -173,7 +169,15 @@ def run(self) -> bool:
173169
bool
174170
"""
175171

176-
cmdl = [self._exe_file.as_posix()]
172+
if platform.system() == "Windows":
173+
path_exe = self._runpath / f"{self._modelname}.exe"
174+
else:
175+
path_exe = self._runpath / self._modelname
176+
177+
if not path_exe.exists():
178+
raise ModelicaSystemError(f"Application file path not found: {path_exe}")
179+
180+
cmdl = [path_exe.as_posix()]
177181
for key in self._args:
178182
if self._args[key] is None:
179183
cmdl.append(f"-{key}")
@@ -220,25 +224,6 @@ def run(self) -> bool:
220224

221225
return True
222226

223-
@staticmethod
224-
def get_exe_file(tempdir: pathlib.Path, modelname: str) -> pathlib.Path:
225-
"""
226-
Get path to model executable.
227-
228-
Parameters
229-
----------
230-
tempdir : pathlib.Path
231-
modelname : str
232-
233-
Returns
234-
-------
235-
pathlib.Path
236-
"""
237-
if platform.system() == "Windows":
238-
return pathlib.Path(tempdir) / f"{modelname}.exe"
239-
else:
240-
return pathlib.Path(tempdir) / modelname
241-
242227
@staticmethod
243228
def parse_simflags(simflags: str) -> dict:
244229
"""

0 commit comments

Comments
 (0)