Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions OMPython/ModelicaSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def __init__(
self._session = OMCSessionLocal(omhome=omhome)

# get OpenModelica version
version_str = self.sendExpression(expr="getVersion()")
version_str = self._session.get_version()
self._version = self._parse_om_version(version=version_str)
# set commandLineOptions using default values or the user defined list
if command_line_options is None:
Expand Down Expand Up @@ -514,8 +514,7 @@ def setWorkDirectory(self, work_directory: Optional[str | os.PathLike] = None) -
raise IOError(f"{workdir} could not be created")

logger.info("Define work dir as %s", workdir)
expr = f'cd("{workdir.as_posix()}")'
self.sendExpression(expr=expr)
self._session.set_workdir(workdir=workdir)

# set the class variable _work_dir ...
self._work_dir = workdir
Expand Down
13 changes: 13 additions & 0 deletions OMPython/OMCSession.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,19 @@ def escape_str(value: str) -> str:
"""
return value.replace("\\", "\\\\").replace('"', '\\"')

def get_version(self) -> str:
"""
Get the OM version.
"""
return self.sendExpression("getVersion()", parsed=True)

def set_workdir(self, workdir: OMCPath) -> None:
"""
Set the workdir for this session.
"""
exp = f'cd("{workdir.as_posix()}")'
self.sendExpression(exp)

def omcpath(self, *path) -> OMCPath:
"""
Create an OMCPath object based on the given path segments and the current OMCSession* class.
Expand Down