Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
[OMCProcessWSL] set omc location via argument wsl_omc
  • Loading branch information
syntron committed Jun 23, 2025
commit 58bbac07bd9b1b2ba8b680e8a891406edd57609f
16 changes: 7 additions & 9 deletions OMPython/OMCSession.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ class OMCProcessWSL(OMCProcess):
def __init__(
self,
timeout: float = 10.00,
omhome: Optional[str] = None,
wsl_omc: str = 'omc',
wsl_distribution: Optional[str] = None,
wsl_user: Optional[str] = None,
) -> None:
Expand All @@ -995,7 +995,7 @@ def __init__(
self._wsl_cmd += ['--']

# where to find OpenModelica
self._omhome = omhome
self._wsl_omc = wsl_omc
# start up omc executable, which is waiting for the ZMQ connection
self._omc_process = self._omc_process_get()
# connect to the running omc instance using ZMQ
Expand All @@ -1004,12 +1004,8 @@ def __init__(
def _omc_process_get(self) -> subprocess.Popen:
my_env = os.environ.copy()

omc_path = 'omc'
if self._omhome is not None:
omc_path = f"{self._omhome}/{omc_path}"

omc_command = self._wsl_cmd + [
omc_path,
self._wsl_omc,
"--locale=C",
"--interactive=zmq",
f"-z={self._random_string}"]
Expand All @@ -1030,8 +1026,10 @@ def _omc_port_get(self) -> str:
try:
omc_portfile_path = self._get_portfile_path()
if omc_portfile_path is not None:
output = subprocess.check_output(args=self._wsl_cmd + ["cat", omc_portfile_path.as_posix()],
stderr=subprocess.DEVNULL)
output = subprocess.check_output(
args=self._wsl_cmd + ["cat", omc_portfile_path.as_posix()],
stderr=subprocess.DEVNULL,
)
port = output.decode().strip()
except subprocess.CalledProcessError:
pass
Expand Down