@@ -1297,25 +1297,30 @@ def __init__(
12971297
12981298 super ().__init__ (timeout = timeout )
12991299
1300- # get wsl base command
1301- self ._wsl_cmd = ['wsl' ]
1302- if isinstance (wsl_distribution , str ):
1303- self ._wsl_cmd += ['--distribution' , wsl_distribution ]
1304- if isinstance (wsl_user , str ):
1305- self ._wsl_cmd += ['--user' , wsl_user ]
1306- self ._wsl_cmd += ['--' ]
1307-
13081300 # where to find OpenModelica
13091301 self ._wsl_omc = wsl_omc
1302+ # store WSL distribution and user
1303+ self ._wsl_distribution = wsl_distribution
1304+ self ._wsl_user = wsl_user
13101305 # start up omc executable, which is waiting for the ZMQ connection
13111306 self ._omc_process = self ._omc_process_get ()
13121307 # connect to the running omc instance using ZMQ
13131308 self ._omc_port = self ._omc_port_get ()
13141309
1310+ def _wsl_cmd (self ) -> list [str ]: # get wsl base command
1311+ wsl_cmd = ['wsl' ]
1312+ if isinstance (self ._wsl_distribution , str ):
1313+ wsl_cmd += ['--distribution' , self ._wsl_distribution ]
1314+ if isinstance (self ._wsl_user , str ):
1315+ wsl_cmd += ['--user' , self ._wsl_user ]
1316+ wsl_cmd += ['--' ]
1317+
1318+ return wsl_cmd
1319+
13151320 def _omc_process_get (self ) -> subprocess .Popen :
13161321 my_env = os .environ .copy ()
13171322
1318- omc_command = self ._wsl_cmd + [
1323+ omc_command = self ._wsl_cmd () + [
13191324 self ._wsl_omc ,
13201325 "--locale=C" ,
13211326 "--interactive=zmq" ,
@@ -1338,7 +1343,7 @@ def _omc_port_get(self) -> str:
13381343 omc_portfile_path = self ._get_portfile_path ()
13391344 if omc_portfile_path is not None :
13401345 output = subprocess .check_output (
1341- args = self ._wsl_cmd + ["cat" , omc_portfile_path .as_posix ()],
1346+ args = self ._wsl_cmd () + ["cat" , omc_portfile_path .as_posix ()],
13421347 stderr = subprocess .DEVNULL ,
13431348 )
13441349 port = output .decode ().strip ()
@@ -1361,4 +1366,17 @@ def _omc_port_get(self) -> str:
13611366 return port
13621367
13631368 def omc_run_data_update (self , omc_run_data : OMCSessionRunData , session : OMCSessionZMQ ) -> OMCSessionRunData :
1364- raise OMCSessionException ("OMCProcessWSL does not support omc_run_data_update()!" )
1369+ """
1370+ Update the OMCSessionRunData object based on the selected OMCProcess implementation.
1371+ """
1372+ omc_run_data_copy = dataclasses .replace (omc_run_data )
1373+
1374+ omc_run_data_copy .cmd_prefix = self ._wsl_cmd ()
1375+
1376+ cmd_path = session .omcpath (omc_run_data_copy .cmd_path )
1377+ cmd_model_executable = cmd_path / omc_run_data_copy .cmd_model_name
1378+ if not cmd_model_executable .is_file ():
1379+ raise OMCSessionException (f"Application file path not found: { cmd_model_executable } " )
1380+ omc_run_data_copy .cmd_model_executable = cmd_model_executable .as_posix ()
1381+
1382+ return omc_run_data_copy
0 commit comments