Skip to content

Commit ee624ca

Browse files
committed
fix pylint hints about (internal) variable names
OMPython/OMCSession.py:1106:8: C0103: Attribute name "_dockerExtraArgs" doesn't conform to snake_case naming style (invalid-name) OMPython/OMCSession.py:1107:8: C0103: Attribute name "_dockerOpenModelicaPath" doesn't conform to snake_case naming style (invalid-name) OMPython/OMCSession.py:1108:8: C0103: Attribute name "_dockerNetwork" doesn't conform to snake_case naming style (invalid-name) OMPython/OMCSession.py:1110:8: C0103: Attribute name "_interactivePort" doesn't conform to snake_case naming style (invalid-name) OMPython/OMCSession.py:1112:8: C0103: Attribute name "_dockerCid" doesn't conform to snake_case naming style (invalid-name) OMPython/OMCSession.py:1121:12: C0103: Variable name "dockerTop" doesn't conform to snake_case naming style (invalid-name) OMPython/OMCSession.py:1282:8: C0103: Variable name "extraFlags" doesn't conform to snake_case naming style (invalid-name) OMPython/OMCSession.py:1297:12: C0103: Variable name "dockerNetworkStr" doesn't conform to snake_case naming style (invalid-name)
1 parent f1156e9 commit ee624ca

1 file changed

Lines changed: 51 additions & 51 deletions

File tree

OMPython/OMCSession.py

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,13 +1077,13 @@ def __init__(
10771077
if dockerExtraArgs is None:
10781078
dockerExtraArgs = []
10791079

1080-
self._dockerExtraArgs = dockerExtraArgs
1081-
self._dockerOpenModelicaPath = pathlib.PurePosixPath(dockerOpenModelicaPath)
1082-
self._dockerNetwork = dockerNetwork
1080+
self._docker_extra_args = dockerExtraArgs
1081+
self._docker_open_modelica_path = pathlib.PurePosixPath(dockerOpenModelicaPath)
1082+
self._docker_network = dockerNetwork
10831083

1084-
self._interactivePort = port
1084+
self._interactive_port = port
10851085

1086-
self._dockerCid: Optional[str] = None
1086+
self._docker_container_id: Optional[str] = None
10871087
self._docker_process: Optional[DockerPopen] = None
10881088

10891089
def _docker_process_get(self, docker_cid: str) -> Optional[DockerPopen]:
@@ -1092,15 +1092,15 @@ def _docker_process_get(self, docker_cid: str) -> Optional[DockerPopen]:
10921092

10931093
docker_process = None
10941094
for _ in range(0, 40):
1095-
dockerTop = subprocess.check_output(["docker", "top", docker_cid]).decode().strip()
1095+
docker_top = subprocess.check_output(["docker", "top", docker_cid]).decode().strip()
10961096
docker_process = None
1097-
for line in dockerTop.split("\n"):
1097+
for line in docker_top.split("\n"):
10981098
columns = line.split()
10991099
if self._random_string in line:
11001100
try:
11011101
docker_process = DockerPopen(int(columns[1]))
11021102
except psutil.NoSuchProcess as ex:
1103-
raise OMCSessionException(f"Could not find PID {dockerTop} - "
1103+
raise OMCSessionException(f"Could not find PID {docker_top} - "
11041104
"is this a docker instance spawned without --pid=host?") from ex
11051105

11061106
if docker_process is not None:
@@ -1123,8 +1123,8 @@ def _getuid() -> int:
11231123
def _omc_port_get(self) -> str:
11241124
port = None
11251125

1126-
if not isinstance(self._dockerCid, str):
1127-
raise OMCSessionException(f"Invalid docker container ID: {self._dockerCid}")
1126+
if not isinstance(self._docker_container_id, str):
1127+
raise OMCSessionException(f"Invalid docker container ID: {self._docker_container_id}")
11281128

11291129
# See if the omc server is running
11301130
attempts = 0
@@ -1133,7 +1133,7 @@ def _omc_port_get(self) -> str:
11331133
if omc_portfile_path is not None:
11341134
try:
11351135
output = subprocess.check_output(args=["docker",
1136-
"exec", self._dockerCid,
1136+
"exec", self._docker_container_id,
11371137
"cat", omc_portfile_path.as_posix()],
11381138
stderr=subprocess.DEVNULL)
11391139
port = output.decode().strip()
@@ -1158,8 +1158,8 @@ def get_server_address(self) -> Optional[str]:
11581158
"""
11591159
Get the server address of the OMC server running in a Docker container.
11601160
"""
1161-
if self._dockerNetwork == "separate" and isinstance(self._dockerCid, str):
1162-
output = subprocess.check_output(["docker", "inspect", self._dockerCid]).decode().strip()
1161+
if self._docker_network == "separate" and isinstance(self._docker_container_id, str):
1162+
output = subprocess.check_output(["docker", "inspect", self._docker_container_id]).decode().strip()
11631163
return json.loads(output)[0]["NetworkSettings"]["IPAddress"]
11641164

11651165
return None
@@ -1168,10 +1168,10 @@ def get_docker_container_id(self) -> str:
11681168
"""
11691169
Get the Docker container ID of the Docker container with the OMC server.
11701170
"""
1171-
if not isinstance(self._dockerCid, str):
1172-
raise OMCSessionException(f"Invalid docker container ID: {self._dockerCid}!")
1171+
if not isinstance(self._docker_container_id, str):
1172+
raise OMCSessionException(f"Invalid docker container ID: {self._docker_container_id}!")
11731173

1174-
return self._dockerCid
1174+
return self._docker_container_id
11751175

11761176
def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunData:
11771177
"""
@@ -1185,8 +1185,8 @@ def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunD
11851185
"--user", str(self._getuid()),
11861186
"--workdir", omc_run_data_copy.cmd_path,
11871187
]
1188-
+ self._dockerExtraArgs
1189-
+ [self._dockerCid]
1188+
+ self._docker_extra_args
1189+
+ [self._docker_container_id]
11901190
)
11911191

11921192
cmd_path = pathlib.PurePosixPath(omc_run_data_copy.cmd_path)
@@ -1225,7 +1225,7 @@ def __init__(
12251225
self._docker = docker
12261226

12271227
# start up omc executable in docker container waiting for the ZMQ connection
1228-
self._omc_process, self._docker_process, self._dockerCid = self._docker_omc_start()
1228+
self._omc_process, self._docker_process, self._docker_container_id = self._docker_omc_start()
12291229
# connect to the running omc instance using ZMQ
12301230
self._omc_port = self._omc_port_get()
12311231

@@ -1253,45 +1253,45 @@ def _docker_omc_cmd(
12531253
"""
12541254
Define the command that will be called by the subprocess module.
12551255
"""
1256-
extraFlags = []
1256+
extra_flags = []
12571257

12581258
if sys.platform == "win32":
1259-
extraFlags = ["-d=zmqDangerousAcceptConnectionsFromAnywhere"]
1260-
if not self._interactivePort:
1259+
extra_flags = ["-d=zmqDangerousAcceptConnectionsFromAnywhere"]
1260+
if not self._interactive_port:
12611261
raise OMCSessionException("docker on Windows requires knowing which port to connect to - "
12621262
"please set the interactivePort argument")
12631263

12641264
if sys.platform == "win32":
1265-
if isinstance(self._interactivePort, str):
1266-
port = int(self._interactivePort)
1267-
elif isinstance(self._interactivePort, int):
1268-
port = self._interactivePort
1265+
if isinstance(self._interactive_port, str):
1266+
port = int(self._interactive_port)
1267+
elif isinstance(self._interactive_port, int):
1268+
port = self._interactive_port
12691269
else:
12701270
raise OMCSessionException("Missing or invalid interactive port!")
1271-
dockerNetworkStr = ["-p", f"127.0.0.1:{port}:{port}"]
1272-
elif self._dockerNetwork == "host" or self._dockerNetwork is None:
1273-
dockerNetworkStr = ["--network=host"]
1274-
elif self._dockerNetwork == "separate":
1275-
dockerNetworkStr = []
1276-
extraFlags = ["-d=zmqDangerousAcceptConnectionsFromAnywhere"]
1271+
docker_network_str = ["-p", f"127.0.0.1:{port}:{port}"]
1272+
elif self._docker_network == "host" or self._docker_network is None:
1273+
docker_network_str = ["--network=host"]
1274+
elif self._docker_network == "separate":
1275+
docker_network_str = []
1276+
extra_flags = ["-d=zmqDangerousAcceptConnectionsFromAnywhere"]
12771277
else:
1278-
raise OMCSessionException(f'dockerNetwork was set to {self._dockerNetwork}, '
1278+
raise OMCSessionException(f'dockerNetwork was set to {self._docker_network}, '
12791279
'but only \"host\" or \"separate\" is allowed')
12801280

1281-
if isinstance(self._interactivePort, int):
1282-
extraFlags = extraFlags + [f"--interactivePort={int(self._interactivePort)}"]
1281+
if isinstance(self._interactive_port, int):
1282+
extra_flags = extra_flags + [f"--interactivePort={int(self._interactive_port)}"]
12831283

12841284
omc_command = ([
12851285
"docker", "run",
12861286
"--cidfile", docker_cid_file.as_posix(),
12871287
"--rm",
12881288
"--user", str(self._getuid()),
12891289
]
1290-
+ self._dockerExtraArgs
1291-
+ dockerNetworkStr
1292-
+ [self._docker, self._dockerOpenModelicaPath.as_posix()]
1290+
+ self._docker_extra_args
1291+
+ docker_network_str
1292+
+ [self._docker, self._docker_open_modelica_path.as_posix()]
12931293
+ omc_path_and_args_list
1294-
+ extraFlags)
1294+
+ extra_flags)
12951295

12961296
return omc_command
12971297

@@ -1365,7 +1365,7 @@ def __init__(
13651365
if not isinstance(dockerContainer, str):
13661366
raise OMCSessionException("Argument dockerContainer must be set!")
13671367

1368-
self._dockerCid = dockerContainer
1368+
self._docker_container_id = dockerContainer
13691369

13701370
# start up omc executable in docker container waiting for the ZMQ connection
13711371
self._omc_process, self._docker_process = self._docker_omc_start()
@@ -1383,27 +1383,27 @@ def _docker_omc_cmd(self, omc_path_and_args_list) -> list:
13831383
"""
13841384
Define the command that will be called by the subprocess module.
13851385
"""
1386-
extraFlags: list[str] = []
1386+
extra_flags: list[str] = []
13871387

13881388
if sys.platform == "win32":
1389-
extraFlags = ["-d=zmqDangerousAcceptConnectionsFromAnywhere"]
1390-
if not self._interactivePort:
1389+
extra_flags = ["-d=zmqDangerousAcceptConnectionsFromAnywhere"]
1390+
if not self._interactive_port:
13911391
raise OMCSessionException("Docker on Windows requires knowing which port to connect to - "
13921392
"Please set the interactivePort argument. Furthermore, the container needs "
13931393
"to have already manually exposed this port when it was started "
13941394
"(-p 127.0.0.1:n:n) or you get an error later.")
13951395

1396-
if isinstance(self._interactivePort, int):
1397-
extraFlags = extraFlags + [f"--interactivePort={int(self._interactivePort)}"]
1396+
if isinstance(self._interactive_port, int):
1397+
extra_flags = extra_flags + [f"--interactivePort={int(self._interactive_port)}"]
13981398

13991399
omc_command = ([
14001400
"docker", "exec",
14011401
"--user", str(self._getuid()),
14021402
]
1403-
+ self._dockerExtraArgs
1404-
+ [self._dockerCid, self._dockerOpenModelicaPath.as_posix()]
1403+
+ self._docker_extra_args
1404+
+ [self._docker_container_id, self._docker_open_modelica_path.as_posix()]
14051405
+ omc_path_and_args_list
1406-
+ extraFlags)
1406+
+ extra_flags)
14071407

14081408
return omc_command
14091409

@@ -1422,12 +1422,12 @@ def _docker_omc_start(self) -> Tuple[subprocess.Popen, DockerPopen]:
14221422
env=my_env)
14231423

14241424
docker_process = None
1425-
if isinstance(self._dockerCid, str):
1426-
docker_process = self._docker_process_get(docker_cid=self._dockerCid)
1425+
if isinstance(self._docker_container_id, str):
1426+
docker_process = self._docker_process_get(docker_cid=self._docker_container_id)
14271427

14281428
if docker_process is None:
14291429
raise OMCSessionException(f"Docker top did not contain omc process {self._random_string} "
1430-
f"/ {self._dockerCid}. Log-file says:\n{self.get_log()}")
1430+
f"/ {self._docker_container_id}. Log-file says:\n{self.get_log()}")
14311431

14321432
return omc_process, docker_process
14331433

0 commit comments

Comments
 (0)