Skip to content

Commit cccb519

Browse files
committed
[ModelicaSystemCmd] split run() - create command in get_cmd() and get_exe()
1 parent 1ffc5b2 commit cccb519

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

OMPython/ModelicaSystem.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,14 @@ def args_set(self, args: dict) -> None:
173173
for arg in args:
174174
self.arg_set(key=arg, val=args[arg])
175175

176-
def run(self) -> bool:
176+
def get_exe(self) -> pathlib.Path:
177177
"""
178-
Run the requested simulation
178+
Get the path to the executable / complied model.
179179
180180
Returns
181181
-------
182-
bool
182+
pathlib.Path
183183
"""
184-
185184
if platform.system() == "Windows":
186185
path_exe = self._runpath / f"{self._modelname}.exe"
187186
else:
@@ -190,6 +189,19 @@ def run(self) -> bool:
190189
if not path_exe.exists():
191190
raise ModelicaSystemError(f"Application file path not found: {path_exe}")
192191

192+
return path_exe
193+
194+
def get_cmd(self) -> list:
195+
"""
196+
Run the requested simulation
197+
198+
Returns
199+
-------
200+
list
201+
"""
202+
203+
path_exe = self.get_exe()
204+
193205
cmdl = [path_exe.as_posix()]
194206
for key in self._args:
195207
if self._args[key] is None:
@@ -200,6 +212,19 @@ def run(self) -> bool:
200212
else:
201213
cmdl.append(f"-{key}={self._args[key]}")
202214

215+
return cmdl
216+
217+
def run(self) -> int:
218+
"""
219+
Run the requested simulation
220+
221+
Returns
222+
-------
223+
int
224+
"""
225+
226+
cmdl: list = self.get_cmd()
227+
203228
logger.debug("Run OM command %s in %s", repr(cmdl), self._runpath.as_posix())
204229

205230
if platform.system() == "Windows":

0 commit comments

Comments
 (0)