Skip to content

Commit 7c4d941

Browse files
committed
??? basic updates - must redo it! (changes not included!)
1 parent 00433b4 commit 7c4d941

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import textwrap
4444
import threading
4545
from typing import Any, cast, Optional
46-
import warnings
4746
import xml.etree.ElementTree as ET
4847

4948
import numpy as np
@@ -732,7 +731,7 @@ def getContinuous(
732731
try:
733732
value = self.getSolutions(name)
734733
self._continuous[name] = value[0][-1]
735-
except (OMCSessionException, ModelicaSystemError) as ex:
734+
except (OMCProcessException, ModelicaSystemError) as ex:
736735
raise ModelicaSystemError(f"{name} could not be computed") from ex
737736
return self._continuous
738737

OMPython/OMCSession.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def is_absolute(self):
321321
Check if the path is an absolute path considering the possibility that we are running locally on Windows. This
322322
case needs special handling as the definition of is_absolute() differs.
323323
"""
324-
if isinstance(self._session, OMCProcessLocal) and platform.system() == 'Windows':
324+
if isinstance(self._omc_process, OMCProcessLocal) and platform.system() == 'Windows':
325325
return pathlib.PureWindowsPath(self.as_posix()).is_absolute()
326326
return super().is_absolute()
327327

@@ -344,8 +344,8 @@ def write_text(self, data: str, encoding=None, errors=None, newline=None):
344344
if not isinstance(data, str):
345345
raise TypeError(f"data must be str, not {data.__class__.__name__}")
346346

347-
data_omc = self._session.escape_str(data)
348-
self._session.sendExpression(f'writeFile("{self.as_posix()}", "{data_omc}", false);')
347+
data_omc = self._omc_process.escape_str(data)
348+
self._omc_process.sendExpression(f'writeFile("{self.as_posix()}", "{data_omc}", false);')
349349

350350
return len(data)
351351

@@ -384,15 +384,15 @@ def resolve(self, strict: bool = False):
384384

385385
if self.is_file():
386386
pathstr_resolved = self._omc_resolve(self.parent.as_posix())
387-
omcpath_resolved = self._session.omcpath(pathstr_resolved) / self.name
387+
omcpath_resolved = self._omc_process.omcpath(pathstr_resolved) / self.name
388388
elif self.is_dir():
389389
pathstr_resolved = self._omc_resolve(self.as_posix())
390-
omcpath_resolved = self._session.omcpath(pathstr_resolved)
390+
omcpath_resolved = self._omc_process.omcpath(pathstr_resolved)
391391
else:
392392
raise OMCProcessException(f"Path {self.as_posix()} is neither a file nor a directory!")
393393

394394
if not omcpath_resolved.is_file() and not omcpath_resolved.is_dir():
395-
raise OMCSessionException(f"OMCPath resolve failed for {self.as_posix()} - path does not exist!")
395+
raise OMCProcessException(f"OMCPath resolve failed for {self.as_posix()} - path does not exist!")
396396

397397
return omcpath_resolved
398398

@@ -735,7 +735,7 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
735735
Caller should only check for OMCSessionException.
736736
"""
737737

738-
# TODO: this is needed if the class is not fully inititialised or in the process of deletion
738+
# TODO: this is needed if the class is not fully initialized or in the process of deletion
739739
if hasattr(self, '_timeout'):
740740
timeout = self._timeout
741741
else:
@@ -770,7 +770,7 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
770770
result = self._omc_zmq.recv_string()
771771

772772
if result.startswith('Error occurred building AST'):
773-
raise OMCSessionException(f"OMC error: {result}")
773+
raise OMCProcessException(f"OMC error: {result}")
774774

775775
if command == "getErrorString()":
776776
# no error handling if 'getErrorString()' is called

0 commit comments

Comments
 (0)