Skip to content

[OMCSessionZMQ] use pathlib.Path() #280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 3, 2025
Merged
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
6 changes: 3 additions & 3 deletions OMPython/OMCSession.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def __init__(self, readonly=False, timeout=10.00,
self._serverIPAddress = "127.0.0.1"
self._interactivePort = None
# FIXME: this code is not well written... need to be refactored
self._temp_dir = tempfile.gettempdir()
self._temp_dir = pathlib.Path(tempfile.gettempdir())
# generate a random string for this session
self._random_string = uuid.uuid4().hex
# omc log file
Expand All @@ -321,7 +321,7 @@ def __init__(self, readonly=False, timeout=10.00,
self._dockerNetwork = dockerNetwork
self._create_omc_log_file("port")
self._timeout = timeout
self._port_file = os.path.join("/tmp" if docker else self._temp_dir, self._port_file).replace("\\", "/")
self._port_file = ((pathlib.Path("/tmp") if docker else self._temp_dir) / self._port_file).as_posix()
self._interactivePort = port
# set omc executable path and args
self._set_omc_command([
Expand Down Expand Up @@ -354,7 +354,7 @@ def _create_omc_log_file(self, suffix):
else:
log_filename = f"openmodelica.{self._currentUser}.{suffix}.{self._random_string}.log"
# this file must be closed in the destructor
self._omc_log_file = open(pathlib.Path(self._temp_dir) / log_filename, "w+")
self._omc_log_file = open(self._temp_dir / log_filename, "w+")

def _start_omc_process(self, timeout):
if sys.platform == 'win32':
Expand Down
Loading