@@ -1387,25 +1387,30 @@ def __init__(
13871387
13881388 super ().__init__ (timeout = timeout )
13891389
1390- # get wsl base command
1391- self ._wsl_cmd = ['wsl' ]
1392- if isinstance (wsl_distribution , str ):
1393- self ._wsl_cmd += ['--distribution' , wsl_distribution ]
1394- if isinstance (wsl_user , str ):
1395- self ._wsl_cmd += ['--user' , wsl_user ]
1396- self ._wsl_cmd += ['--' ]
1397-
13981390 # where to find OpenModelica
13991391 self ._wsl_omc = wsl_omc
1392+ # store WSL distribution and user
1393+ self ._wsl_distribution = wsl_distribution
1394+ self ._wsl_user = wsl_user
14001395 # start up omc executable, which is waiting for the ZMQ connection
14011396 self ._omc_process = self ._omc_process_get ()
14021397 # connect to the running omc instance using ZMQ
14031398 self ._omc_port = self ._omc_port_get ()
14041399
1400+ def _wsl_cmd (self ) -> list [str ]: # get wsl base command
1401+ wsl_cmd = ['wsl' ]
1402+ if isinstance (self ._wsl_distribution , str ):
1403+ wsl_cmd += ['--distribution' , self ._wsl_distribution ]
1404+ if isinstance (self ._wsl_user , str ):
1405+ wsl_cmd += ['--user' , self ._wsl_user ]
1406+ wsl_cmd += ['--' ]
1407+
1408+ return wsl_cmd
1409+
14051410 def _omc_process_get (self ) -> subprocess .Popen :
14061411 my_env = os .environ .copy ()
14071412
1408- omc_command = self ._wsl_cmd + [
1413+ omc_command = self ._wsl_cmd () + [
14091414 self ._wsl_omc ,
14101415 "--locale=C" ,
14111416 "--interactive=zmq" ,
@@ -1428,7 +1433,7 @@ def _omc_port_get(self) -> str:
14281433 omc_portfile_path = self ._get_portfile_path ()
14291434 if omc_portfile_path is not None :
14301435 output = subprocess .check_output (
1431- args = self ._wsl_cmd + ["cat" , omc_portfile_path .as_posix ()],
1436+ args = self ._wsl_cmd () + ["cat" , omc_portfile_path .as_posix ()],
14321437 stderr = subprocess .DEVNULL ,
14331438 )
14341439 port = output .decode ().strip ()
@@ -1454,4 +1459,14 @@ def omc_run_data_update(self, omc_run_data: OMCSessionRunData, session: OMCSessi
14541459 """
14551460 Update the OMCSessionRunData object based on the selected OMCProcess implementation.
14561461 """
1457- raise OMCSessionException ("OMCProcessWSL does not support omc_run_data_update()!" )
1462+ omc_run_data_copy = dataclasses .replace (omc_run_data )
1463+
1464+ omc_run_data_copy .cmd_prefix = self ._wsl_cmd ()
1465+
1466+ cmd_path = session .omcpath (omc_run_data_copy .cmd_path )
1467+ cmd_model_executable = cmd_path / omc_run_data_copy .cmd_model_name
1468+ if not cmd_model_executable .is_file ():
1469+ raise OMCSessionException (f"Application file path not found: { cmd_model_executable } " )
1470+ omc_run_data_copy .cmd_model_executable = cmd_model_executable .as_posix ()
1471+
1472+ return omc_run_data_copy
0 commit comments