@@ -1109,13 +1109,13 @@ def __init__(
11091109 if dockerExtraArgs is None :
11101110 dockerExtraArgs = []
11111111
1112- self ._dockerExtraArgs = dockerExtraArgs
1113- self ._dockerOpenModelicaPath = pathlib .PurePosixPath (dockerOpenModelicaPath )
1114- self ._dockerNetwork = dockerNetwork
1112+ self ._docker_extra_args = dockerExtraArgs
1113+ self ._docker_open_modelica_path = pathlib .PurePosixPath (dockerOpenModelicaPath )
1114+ self ._docker_network = dockerNetwork
11151115
1116- self ._interactivePort = port
1116+ self ._interactive_port = port
11171117
1118- self ._dockerCid : Optional [str ] = None
1118+ self ._docker_container_id : Optional [str ] = None
11191119 self ._docker_process : Optional [DockerPopen ] = None
11201120
11211121 def _docker_process_get (self , docker_cid : str ) -> Optional [DockerPopen ]:
@@ -1124,15 +1124,15 @@ def _docker_process_get(self, docker_cid: str) -> Optional[DockerPopen]:
11241124
11251125 docker_process = None
11261126 for _ in range (0 , 40 ):
1127- dockerTop = subprocess .check_output (["docker" , "top" , docker_cid ]).decode ().strip ()
1127+ docker_top = subprocess .check_output (["docker" , "top" , docker_cid ]).decode ().strip ()
11281128 docker_process = None
1129- for line in dockerTop .split ("\n " ):
1129+ for line in docker_top .split ("\n " ):
11301130 columns = line .split ()
11311131 if self ._random_string in line :
11321132 try :
11331133 docker_process = DockerPopen (int (columns [1 ]))
11341134 except psutil .NoSuchProcess as ex :
1135- raise OMCSessionException (f"Could not find PID { dockerTop } - "
1135+ raise OMCSessionException (f"Could not find PID { docker_top } - "
11361136 "is this a docker instance spawned without --pid=host?" ) from ex
11371137
11381138 if docker_process is not None :
@@ -1155,8 +1155,8 @@ def _getuid() -> int:
11551155 def _omc_port_get (self ) -> str :
11561156 port = None
11571157
1158- if not isinstance (self ._dockerCid , str ):
1159- raise OMCSessionException (f"Invalid docker container ID: { self ._dockerCid } " )
1158+ if not isinstance (self ._docker_container_id , str ):
1159+ raise OMCSessionException (f"Invalid docker container ID: { self ._docker_container_id } " )
11601160
11611161 # See if the omc server is running
11621162 attempts = 0
@@ -1165,7 +1165,7 @@ def _omc_port_get(self) -> str:
11651165 if omc_portfile_path is not None :
11661166 try :
11671167 output = subprocess .check_output (args = ["docker" ,
1168- "exec" , self ._dockerCid ,
1168+ "exec" , self ._docker_container_id ,
11691169 "cat" , omc_portfile_path .as_posix ()],
11701170 stderr = subprocess .DEVNULL )
11711171 port = output .decode ().strip ()
@@ -1190,8 +1190,8 @@ def get_server_address(self) -> Optional[str]:
11901190 """
11911191 Get the server address of the OMC server running in a Docker container.
11921192 """
1193- if self ._dockerNetwork == "separate" and isinstance (self ._dockerCid , str ):
1194- output = subprocess .check_output (["docker" , "inspect" , self ._dockerCid ]).decode ().strip ()
1193+ if self ._docker_network == "separate" and isinstance (self ._docker_container_id , str ):
1194+ output = subprocess .check_output (["docker" , "inspect" , self ._docker_container_id ]).decode ().strip ()
11951195 return json .loads (output )[0 ]["NetworkSettings" ]["IPAddress" ]
11961196
11971197 return None
@@ -1200,10 +1200,10 @@ def get_docker_container_id(self) -> str:
12001200 """
12011201 Get the Docker container ID of the Docker container with the OMC server.
12021202 """
1203- if not isinstance (self ._dockerCid , str ):
1204- raise OMCSessionException (f"Invalid docker container ID: { self ._dockerCid } !" )
1203+ if not isinstance (self ._docker_container_id , str ):
1204+ raise OMCSessionException (f"Invalid docker container ID: { self ._docker_container_id } !" )
12051205
1206- return self ._dockerCid
1206+ return self ._docker_container_id
12071207
12081208 def omc_run_data_update (self , omc_run_data : OMCSessionRunData ) -> OMCSessionRunData :
12091209 """
@@ -1217,8 +1217,8 @@ def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunD
12171217 "--user" , str (self ._getuid ()),
12181218 "--workdir" , omc_run_data_copy .cmd_path ,
12191219 ]
1220- + self ._dockerExtraArgs
1221- + [self ._dockerCid ]
1220+ + self ._docker_extra_args
1221+ + [self ._docker_container_id ]
12221222 )
12231223
12241224 cmd_path = pathlib .PurePosixPath (omc_run_data_copy .cmd_path )
@@ -1257,7 +1257,7 @@ def __init__(
12571257 self ._docker = docker
12581258
12591259 # start up omc executable in docker container waiting for the ZMQ connection
1260- self ._omc_process , self ._docker_process , self ._dockerCid = self ._docker_omc_start ()
1260+ self ._omc_process , self ._docker_process , self ._docker_container_id = self ._docker_omc_start ()
12611261 # connect to the running omc instance using ZMQ
12621262 self ._omc_port = self ._omc_port_get ()
12631263
@@ -1285,45 +1285,45 @@ def _docker_omc_cmd(
12851285 """
12861286 Define the command that will be called by the subprocess module.
12871287 """
1288- extraFlags = []
1288+ extra_flags = []
12891289
12901290 if sys .platform == "win32" :
1291- extraFlags = ["-d=zmqDangerousAcceptConnectionsFromAnywhere" ]
1292- if not self ._interactivePort :
1291+ extra_flags = ["-d=zmqDangerousAcceptConnectionsFromAnywhere" ]
1292+ if not self ._interactive_port :
12931293 raise OMCSessionException ("docker on Windows requires knowing which port to connect to - "
12941294 "please set the interactivePort argument" )
12951295
12961296 if sys .platform == "win32" :
1297- if isinstance (self ._interactivePort , str ):
1298- port = int (self ._interactivePort )
1299- elif isinstance (self ._interactivePort , int ):
1300- port = self ._interactivePort
1297+ if isinstance (self ._interactive_port , str ):
1298+ port = int (self ._interactive_port )
1299+ elif isinstance (self ._interactive_port , int ):
1300+ port = self ._interactive_port
13011301 else :
13021302 raise OMCSessionException ("Missing or invalid interactive port!" )
1303- dockerNetworkStr = ["-p" , f"127.0.0.1:{ port } :{ port } " ]
1304- elif self ._dockerNetwork == "host" or self ._dockerNetwork is None :
1305- dockerNetworkStr = ["--network=host" ]
1306- elif self ._dockerNetwork == "separate" :
1307- dockerNetworkStr = []
1308- extraFlags = ["-d=zmqDangerousAcceptConnectionsFromAnywhere" ]
1303+ docker_network_str = ["-p" , f"127.0.0.1:{ port } :{ port } " ]
1304+ elif self ._docker_network == "host" or self ._docker_network is None :
1305+ docker_network_str = ["--network=host" ]
1306+ elif self ._docker_network == "separate" :
1307+ docker_network_str = []
1308+ extra_flags = ["-d=zmqDangerousAcceptConnectionsFromAnywhere" ]
13091309 else :
1310- raise OMCSessionException (f'dockerNetwork was set to { self ._dockerNetwork } , '
1310+ raise OMCSessionException (f'dockerNetwork was set to { self ._docker_network } , '
13111311 'but only \" host\" or \" separate\" is allowed' )
13121312
1313- if isinstance (self ._interactivePort , int ):
1314- extraFlags = extraFlags + [f"--interactivePort={ int (self ._interactivePort )} " ]
1313+ if isinstance (self ._interactive_port , int ):
1314+ extra_flags = extra_flags + [f"--interactivePort={ int (self ._interactive_port )} " ]
13151315
13161316 omc_command = ([
13171317 "docker" , "run" ,
13181318 "--cidfile" , docker_cid_file .as_posix (),
13191319 "--rm" ,
13201320 "--user" , str (self ._getuid ()),
13211321 ]
1322- + self ._dockerExtraArgs
1323- + dockerNetworkStr
1324- + [self ._docker , self ._dockerOpenModelicaPath .as_posix ()]
1322+ + self ._docker_extra_args
1323+ + docker_network_str
1324+ + [self ._docker , self ._docker_open_modelica_path .as_posix ()]
13251325 + omc_path_and_args_list
1326- + extraFlags )
1326+ + extra_flags )
13271327
13281328 return omc_command
13291329
@@ -1397,7 +1397,7 @@ def __init__(
13971397 if not isinstance (dockerContainer , str ):
13981398 raise OMCSessionException ("Argument dockerContainer must be set!" )
13991399
1400- self ._dockerCid = dockerContainer
1400+ self ._docker_container_id = dockerContainer
14011401
14021402 # start up omc executable in docker container waiting for the ZMQ connection
14031403 self ._omc_process , self ._docker_process = self ._docker_omc_start ()
@@ -1415,27 +1415,27 @@ def _docker_omc_cmd(self, omc_path_and_args_list) -> list:
14151415 """
14161416 Define the command that will be called by the subprocess module.
14171417 """
1418- extraFlags : list [str ] = []
1418+ extra_flags : list [str ] = []
14191419
14201420 if sys .platform == "win32" :
1421- extraFlags = ["-d=zmqDangerousAcceptConnectionsFromAnywhere" ]
1422- if not self ._interactivePort :
1421+ extra_flags = ["-d=zmqDangerousAcceptConnectionsFromAnywhere" ]
1422+ if not self ._interactive_port :
14231423 raise OMCSessionException ("Docker on Windows requires knowing which port to connect to - "
14241424 "Please set the interactivePort argument. Furthermore, the container needs "
14251425 "to have already manually exposed this port when it was started "
14261426 "(-p 127.0.0.1:n:n) or you get an error later." )
14271427
1428- if isinstance (self ._interactivePort , int ):
1429- extraFlags = extraFlags + [f"--interactivePort={ int (self ._interactivePort )} " ]
1428+ if isinstance (self ._interactive_port , int ):
1429+ extra_flags = extra_flags + [f"--interactivePort={ int (self ._interactive_port )} " ]
14301430
14311431 omc_command = ([
14321432 "docker" , "exec" ,
14331433 "--user" , str (self ._getuid ()),
14341434 ]
1435- + self ._dockerExtraArgs
1436- + [self ._dockerCid , self ._dockerOpenModelicaPath .as_posix ()]
1435+ + self ._docker_extra_args
1436+ + [self ._docker_container_id , self ._docker_open_modelica_path .as_posix ()]
14371437 + omc_path_and_args_list
1438- + extraFlags )
1438+ + extra_flags )
14391439
14401440 return omc_command
14411441
@@ -1454,12 +1454,12 @@ def _docker_omc_start(self) -> Tuple[subprocess.Popen, DockerPopen]:
14541454 env = my_env )
14551455
14561456 docker_process = None
1457- if isinstance (self ._dockerCid , str ):
1458- docker_process = self ._docker_process_get (docker_cid = self ._dockerCid )
1457+ if isinstance (self ._docker_container_id , str ):
1458+ docker_process = self ._docker_process_get (docker_cid = self ._docker_container_id )
14591459
14601460 if docker_process is None :
14611461 raise OMCSessionException (f"Docker top did not contain omc process { self ._random_string } "
1462- f"/ { self ._dockerCid } . Log-file says:\n { self .get_log ()} " )
1462+ f"/ { self ._docker_container_id } . Log-file says:\n { self .get_log ()} " )
14631463
14641464 return omc_process , docker_process
14651465
0 commit comments