Skip to content

Commit d90b51f

Browse files
committed
??? cleanup
1 parent 7c4d941 commit d90b51f

2 files changed

Lines changed: 8 additions & 13 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,13 +424,13 @@ def model(
424424
if model_file is not None:
425425
file_path = pathlib.Path(model_file)
426426
# special handling for OMCProcessLocal - consider a relative path
427-
if isinstance(self._session.omc_process, OMCProcessLocal) and not file_path.is_absolute():
427+
if isinstance(self.get_omc_process(), OMCProcessLocal) and not file_path.is_absolute():
428428
file_path = pathlib.Path.cwd() / file_path
429429
if not file_path.is_file():
430430
raise IOError(f"Model file {file_path} does not exist!")
431431

432432
self._file_name = self.getWorkDirectory() / file_path.name
433-
if (isinstance(self._session.omc_process, OMCProcessLocal)
433+
if (isinstance(self.get_omc_process(), OMCProcessLocal)
434434
and file_path.as_posix() == self._file_name.as_posix()):
435435
pass
436436
elif self._file_name.is_file():
@@ -1148,12 +1148,12 @@ def plot(
11481148
plot is created by OMC which needs access to the local display. This is not the case for docker and WSL.
11491149
"""
11501150

1151-
if not isinstance(self._session.omc_process, OMCProcessLocal):
1151+
if not isinstance(self.get_omc_process(), OMCProcessLocal):
11521152
raise ModelicaSystemError("Plot is using the OMC plot functionality; "
11531153
"thus, it is only working if OMC is running locally!")
11541154

11551155
if resultfile is not None:
1156-
plot_result_file = self._session.omcpath(resultfile)
1156+
plot_result_file = self.get_omc_process().omcpath(resultfile)
11571157
elif self._result_file is not None:
11581158
plot_result_file = self._result_file
11591159
else:
@@ -1553,7 +1553,7 @@ def convertMo2Fmu(
15531553
properties = (f'version="{version}", fmuType="{fmuType}", '
15541554
f'fileNamePrefix="{fileNamePrefix}", includeResources={include_resources_str}')
15551555
fmu = self._requestApi(apiName='buildModelFMU', entity=self._model_name, properties=properties)
1556-
fmu_path = self._session.omcpath(fmu)
1556+
fmu_path = self.get_omc_process().omcpath(fmu)
15571557

15581558
# report proper error message
15591559
if not fmu_path.is_file():
@@ -1574,7 +1574,7 @@ def convertFmu2Mo(
15741574
>>> convertFmu2Mo("c:/BouncingBall.Fmu")
15751575
"""
15761576

1577-
fmu_path = self._session.omcpath(fmu)
1577+
fmu_path = self.get_omc_process().omcpath(fmu)
15781578

15791579
if not fmu_path.is_file():
15801580
raise ModelicaSystemError(f"Missing FMU file: {fmu_path.as_posix()}")

OMPython/OMCSession.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -410,15 +410,10 @@ def _omc_resolve(self, pathstr: str) -> str:
410410
result_parts = result.split('\n')
411411
pathstr_resolved = result_parts[1]
412412
pathstr_resolved = pathstr_resolved[1:-1] # remove quotes
413-
414-
omcpath_resolved = self._omc_process.omcpath(pathstr_resolved)
415413
except OMCProcessException as ex:
416414
raise OMCProcessException(f"OMCPath resolve failed for {pathstr}!") from ex
417415

418-
if not omcpath_resolved.is_file() and not omcpath_resolved.is_dir():
419-
raise OMCProcessException(f"OMCPath resolve failed for {pathstr} - path does not exist!")
420-
421-
return omcpath_resolved
416+
return pathstr_resolved
422417

423418
def absolute(self):
424419
"""
@@ -854,7 +849,7 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
854849
msg_long_list.append(msg_long)
855850
if has_error:
856851
msg_long_str = '\n'.join(f"{idx:02d}: {msg}" for idx, msg in enumerate(msg_long_list))
857-
raise OMCSessionException(f"OMC error occurred for 'sendExpression({command}, {parsed}):\n"
852+
raise OMCProcessException(f"OMC error occurred for 'sendExpression({command}, {parsed}):\n"
858853
f"{msg_long_str}")
859854

860855
if parsed is False:

0 commit comments

Comments
 (0)