@@ -1265,25 +1265,30 @@ def __init__(
12651265
12661266 super ().__init__ (timeout = timeout )
12671267
1268- # get wsl base command
1269- self ._wsl_cmd = ['wsl' ]
1270- if isinstance (wsl_distribution , str ):
1271- self ._wsl_cmd += ['--distribution' , wsl_distribution ]
1272- if isinstance (wsl_user , str ):
1273- self ._wsl_cmd += ['--user' , wsl_user ]
1274- self ._wsl_cmd += ['--' ]
1275-
12761268 # where to find OpenModelica
12771269 self ._wsl_omc = wsl_omc
1270+ # store WSL distribution and user
1271+ self ._wsl_distribution = wsl_distribution
1272+ self ._wsl_user = wsl_user
12781273 # start up omc executable, which is waiting for the ZMQ connection
12791274 self ._omc_process = self ._omc_process_get ()
12801275 # connect to the running omc instance using ZMQ
12811276 self ._omc_port = self ._omc_port_get ()
12821277
1278+ def _wsl_cmd (self ) -> list [str ]: # get wsl base command
1279+ wsl_cmd = ['wsl' ]
1280+ if isinstance (self ._wsl_distribution , str ):
1281+ wsl_cmd += ['--distribution' , self ._wsl_distribution ]
1282+ if isinstance (self ._wsl_user , str ):
1283+ wsl_cmd += ['--user' , self ._wsl_user ]
1284+ wsl_cmd += ['--' ]
1285+
1286+ return wsl_cmd
1287+
12831288 def _omc_process_get (self ) -> subprocess .Popen :
12841289 my_env = os .environ .copy ()
12851290
1286- omc_command = self ._wsl_cmd + [
1291+ omc_command = self ._wsl_cmd () + [
12871292 self ._wsl_omc ,
12881293 "--locale=C" ,
12891294 "--interactive=zmq" ,
@@ -1306,7 +1311,7 @@ def _omc_port_get(self) -> str:
13061311 omc_portfile_path = self ._get_portfile_path ()
13071312 if omc_portfile_path is not None :
13081313 output = subprocess .check_output (
1309- args = self ._wsl_cmd + ["cat" , omc_portfile_path .as_posix ()],
1314+ args = self ._wsl_cmd () + ["cat" , omc_portfile_path .as_posix ()],
13101315 stderr = subprocess .DEVNULL ,
13111316 )
13121317 port = output .decode ().strip ()
@@ -1329,4 +1334,17 @@ def _omc_port_get(self) -> str:
13291334 return port
13301335
13311336 def omc_run_data_update (self , omc_run_data : OMCSessionRunData , session : OMCSessionZMQ ) -> OMCSessionRunData :
1332- raise OMCSessionException ("OMCProcessWSL does not support omc_run_data_update()!" )
1337+ """
1338+ Update the OMCSessionRunData object based on the selected OMCProcess implementation.
1339+ """
1340+ omc_run_data_copy = dataclasses .replace (omc_run_data )
1341+
1342+ omc_run_data_copy .cmd_prefix = self ._wsl_cmd ()
1343+
1344+ cmd_path = session .omcpath (omc_run_data_copy .cmd_path )
1345+ cmd_model_executable = cmd_path / omc_run_data_copy .cmd_model_name
1346+ if not cmd_model_executable .is_file ():
1347+ raise OMCSessionException (f"Application file path not found: { cmd_model_executable } " )
1348+ omc_run_data_copy .cmd_model_executable = cmd_model_executable .as_posix ()
1349+
1350+ return omc_run_data_copy
0 commit comments