Skip to content

Commit de7b5d6

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 2caa7db commit de7b5d6

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
@@ -1084,13 +1084,13 @@ def __init__(
10841084
if dockerExtraArgs is None:
10851085
dockerExtraArgs = []
10861086

1087-
self._dockerExtraArgs = dockerExtraArgs
1088-
self._dockerOpenModelicaPath = pathlib.PurePosixPath(dockerOpenModelicaPath)
1089-
self._dockerNetwork = dockerNetwork
1087+
self._docker_extra_args = dockerExtraArgs
1088+
self._docker_open_modelica_path = pathlib.PurePosixPath(dockerOpenModelicaPath)
1089+
self._docker_network = dockerNetwork
10901090

1091-
self._interactivePort = port
1091+
self._interactive_port = port
10921092

1093-
self._dockerCid: Optional[str] = None
1093+
self._docker_container_id: Optional[str] = None
10941094
self._docker_process: Optional[DockerPopen] = None
10951095

10961096
def _docker_process_get(self, docker_cid: str) -> Optional[DockerPopen]:
@@ -1099,15 +1099,15 @@ def _docker_process_get(self, docker_cid: str) -> Optional[DockerPopen]:
10991099

11001100
docker_process = None
11011101
for _ in range(0, 40):
1102-
dockerTop = subprocess.check_output(["docker", "top", docker_cid]).decode().strip()
1102+
docker_top = subprocess.check_output(["docker", "top", docker_cid]).decode().strip()
11031103
docker_process = None
1104-
for line in dockerTop.split("\n"):
1104+
for line in docker_top.split("\n"):
11051105
columns = line.split()
11061106
if self._random_string in line:
11071107
try:
11081108
docker_process = DockerPopen(int(columns[1]))
11091109
except psutil.NoSuchProcess as ex:
1110-
raise OMCSessionException(f"Could not find PID {dockerTop} - "
1110+
raise OMCSessionException(f"Could not find PID {docker_top} - "
11111111
"is this a docker instance spawned without --pid=host?") from ex
11121112

11131113
if docker_process is not None:
@@ -1130,8 +1130,8 @@ def _getuid() -> int:
11301130
def _omc_port_get(self) -> str:
11311131
port = None
11321132

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

11361136
# See if the omc server is running
11371137
attempts = 0
@@ -1140,7 +1140,7 @@ def _omc_port_get(self) -> str:
11401140
if omc_portfile_path is not None:
11411141
try:
11421142
output = subprocess.check_output(args=["docker",
1143-
"exec", self._dockerCid,
1143+
"exec", self._docker_container_id,
11441144
"cat", omc_portfile_path.as_posix()],
11451145
stderr=subprocess.DEVNULL)
11461146
port = output.decode().strip()
@@ -1165,8 +1165,8 @@ def get_server_address(self) -> Optional[str]:
11651165
"""
11661166
Get the server address of the OMC server running in a Docker container.
11671167
"""
1168-
if self._dockerNetwork == "separate" and isinstance(self._dockerCid, str):
1169-
output = subprocess.check_output(["docker", "inspect", self._dockerCid]).decode().strip()
1168+
if self._docker_network == "separate" and isinstance(self._docker_container_id, str):
1169+
output = subprocess.check_output(["docker", "inspect", self._docker_container_id]).decode().strip()
11701170
return json.loads(output)[0]["NetworkSettings"]["IPAddress"]
11711171

11721172
return None
@@ -1175,10 +1175,10 @@ def get_docker_container_id(self) -> str:
11751175
"""
11761176
Get the Docker container ID of the Docker container with the OMC server.
11771177
"""
1178-
if not isinstance(self._dockerCid, str):
1179-
raise OMCSessionException(f"Invalid docker container ID: {self._dockerCid}!")
1178+
if not isinstance(self._docker_container_id, str):
1179+
raise OMCSessionException(f"Invalid docker container ID: {self._docker_container_id}!")
11801180

1181-
return self._dockerCid
1181+
return self._docker_container_id
11821182

11831183
def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunData:
11841184
"""
@@ -1192,8 +1192,8 @@ def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunD
11921192
"--user", str(self._getuid()),
11931193
"--workdir", omc_run_data_copy.cmd_path,
11941194
]
1195-
+ self._dockerExtraArgs
1196-
+ [self._dockerCid]
1195+
+ self._docker_extra_args
1196+
+ [self._docker_container_id]
11971197
)
11981198

11991199
cmd_path = pathlib.PurePosixPath(omc_run_data_copy.cmd_path)
@@ -1232,7 +1232,7 @@ def __init__(
12321232
self._docker = docker
12331233

12341234
# start up omc executable in docker container waiting for the ZMQ connection
1235-
self._omc_process, self._docker_process, self._dockerCid = self._docker_omc_start()
1235+
self._omc_process, self._docker_process, self._docker_container_id = self._docker_omc_start()
12361236
# connect to the running omc instance using ZMQ
12371237
self._omc_port = self._omc_port_get()
12381238

@@ -1260,45 +1260,45 @@ def _docker_omc_cmd(
12601260
"""
12611261
Define the command that will be called by the subprocess module.
12621262
"""
1263-
extraFlags = []
1263+
extra_flags = []
12641264

12651265
if sys.platform == "win32":
1266-
extraFlags = ["-d=zmqDangerousAcceptConnectionsFromAnywhere"]
1267-
if not self._interactivePort:
1266+
extra_flags = ["-d=zmqDangerousAcceptConnectionsFromAnywhere"]
1267+
if not self._interactive_port:
12681268
raise OMCSessionException("docker on Windows requires knowing which port to connect to - "
12691269
"please set the interactivePort argument")
12701270

12711271
if sys.platform == "win32":
1272-
if isinstance(self._interactivePort, str):
1273-
port = int(self._interactivePort)
1274-
elif isinstance(self._interactivePort, int):
1275-
port = self._interactivePort
1272+
if isinstance(self._interactive_port, str):
1273+
port = int(self._interactive_port)
1274+
elif isinstance(self._interactive_port, int):
1275+
port = self._interactive_port
12761276
else:
12771277
raise OMCSessionException("Missing or invalid interactive port!")
1278-
dockerNetworkStr = ["-p", f"127.0.0.1:{port}:{port}"]
1279-
elif self._dockerNetwork == "host" or self._dockerNetwork is None:
1280-
dockerNetworkStr = ["--network=host"]
1281-
elif self._dockerNetwork == "separate":
1282-
dockerNetworkStr = []
1283-
extraFlags = ["-d=zmqDangerousAcceptConnectionsFromAnywhere"]
1278+
docker_network_str = ["-p", f"127.0.0.1:{port}:{port}"]
1279+
elif self._docker_network == "host" or self._docker_network is None:
1280+
docker_network_str = ["--network=host"]
1281+
elif self._docker_network == "separate":
1282+
docker_network_str = []
1283+
extra_flags = ["-d=zmqDangerousAcceptConnectionsFromAnywhere"]
12841284
else:
1285-
raise OMCSessionException(f'dockerNetwork was set to {self._dockerNetwork}, '
1285+
raise OMCSessionException(f'dockerNetwork was set to {self._docker_network}, '
12861286
'but only \"host\" or \"separate\" is allowed')
12871287

1288-
if isinstance(self._interactivePort, int):
1289-
extraFlags = extraFlags + [f"--interactivePort={int(self._interactivePort)}"]
1288+
if isinstance(self._interactive_port, int):
1289+
extra_flags = extra_flags + [f"--interactivePort={int(self._interactive_port)}"]
12901290

12911291
omc_command = ([
12921292
"docker", "run",
12931293
"--cidfile", docker_cid_file.as_posix(),
12941294
"--rm",
12951295
"--user", str(self._getuid()),
12961296
]
1297-
+ self._dockerExtraArgs
1298-
+ dockerNetworkStr
1299-
+ [self._docker, self._dockerOpenModelicaPath.as_posix()]
1297+
+ self._docker_extra_args
1298+
+ docker_network_str
1299+
+ [self._docker, self._docker_open_modelica_path.as_posix()]
13001300
+ omc_path_and_args_list
1301-
+ extraFlags)
1301+
+ extra_flags)
13021302

13031303
return omc_command
13041304

@@ -1372,7 +1372,7 @@ def __init__(
13721372
if not isinstance(dockerContainer, str):
13731373
raise OMCSessionException("Argument dockerContainer must be set!")
13741374

1375-
self._dockerCid = dockerContainer
1375+
self._docker_container_id = dockerContainer
13761376

13771377
# start up omc executable in docker container waiting for the ZMQ connection
13781378
self._omc_process, self._docker_process = self._docker_omc_start()
@@ -1390,27 +1390,27 @@ def _docker_omc_cmd(self, omc_path_and_args_list) -> list:
13901390
"""
13911391
Define the command that will be called by the subprocess module.
13921392
"""
1393-
extraFlags: list[str] = []
1393+
extra_flags: list[str] = []
13941394

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

1403-
if isinstance(self._interactivePort, int):
1404-
extraFlags = extraFlags + [f"--interactivePort={int(self._interactivePort)}"]
1403+
if isinstance(self._interactive_port, int):
1404+
extra_flags = extra_flags + [f"--interactivePort={int(self._interactive_port)}"]
14051405

14061406
omc_command = ([
14071407
"docker", "exec",
14081408
"--user", str(self._getuid()),
14091409
]
1410-
+ self._dockerExtraArgs
1411-
+ [self._dockerCid, self._dockerOpenModelicaPath.as_posix()]
1410+
+ self._docker_extra_args
1411+
+ [self._docker_container_id, self._docker_open_modelica_path.as_posix()]
14121412
+ omc_path_and_args_list
1413-
+ extraFlags)
1413+
+ extra_flags)
14141414

14151415
return omc_command
14161416

@@ -1429,12 +1429,12 @@ def _docker_omc_start(self) -> Tuple[subprocess.Popen, DockerPopen]:
14291429
env=my_env)
14301430

14311431
docker_process = None
1432-
if isinstance(self._dockerCid, str):
1433-
docker_process = self._docker_process_get(docker_cid=self._dockerCid)
1432+
if isinstance(self._docker_container_id, str):
1433+
docker_process = self._docker_process_get(docker_cid=self._docker_container_id)
14341434

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

14391439
return omc_process, docker_process
14401440

0 commit comments

Comments
 (0)