|
57 | 57 | from OMPython.OMTypedParser import parseString as om_parser_typed |
58 | 58 | from OMPython.OMParser import om_parser_basic |
59 | 59 |
|
60 | | - |
61 | 60 | # define logger using the current module name as ID |
62 | 61 | logger = logging.getLogger(__name__) |
63 | 62 |
|
@@ -314,11 +313,9 @@ def __init__(self, timeout=10.00, |
314 | 313 | self._port_file = ((pathlib.Path("/tmp") if docker else self._temp_dir) / self._port_file).as_posix() |
315 | 314 | self._interactivePort = port |
316 | 315 | # set omc executable path and args |
317 | | - self._set_omc_command([ |
318 | | - "--interactive=zmq", |
319 | | - "--locale=C", |
320 | | - f"-z={self._random_string}" |
321 | | - ]) |
| 316 | + self._set_omc_command(omc_path_and_args_list=["--interactive=zmq", |
| 317 | + "--locale=C", |
| 318 | + f"-z={self._random_string}"]) |
322 | 319 | # start up omc executable, which is waiting for the ZMQ connection |
323 | 320 | self._start_omc_process(timeout) |
324 | 321 | # connect to the running omc instance using ZMQ |
@@ -385,7 +382,8 @@ def _start_omc_process(self, timeout): |
385 | 382 | dockerTop = None |
386 | 383 | if self._docker or self._dockerContainer: |
387 | 384 | if self._dockerNetwork == "separate": |
388 | | - self._serverIPAddress = json.loads(subprocess.check_output(["docker", "inspect", self._dockerCid]).decode().strip())[0]["NetworkSettings"]["IPAddress"] |
| 385 | + output = subprocess.check_output(["docker", "inspect", self._dockerCid]).decode().strip() |
| 386 | + self._serverIPAddress = json.loads(output)[0]["NetworkSettings"]["IPAddress"] |
389 | 387 | for i in range(0, 40): |
390 | 388 | if sys.platform == 'win32': |
391 | 389 | break |
@@ -444,9 +442,20 @@ def _set_omc_command(self, omc_path_and_args_list): |
444 | 442 | else: |
445 | 443 | raise OMCSessionException('dockerNetwork was set to %s, but only \"host\" or \"separate\" is allowed') |
446 | 444 | self._dockerCidFile = self._omc_log_file.name + ".docker.cid" |
447 | | - omcCommand = ["docker", "run", "--cidfile", self._dockerCidFile, "--rm", "--env", "USER=%s" % self._currentUser, "--user", str(self._getuid())] + self._dockerExtraArgs + dockerNetworkStr + [self._docker, self._dockerOpenModelicaPath] |
| 445 | + omcCommand = (["docker", "run", |
| 446 | + "--cidfile", self._dockerCidFile, |
| 447 | + "--rm", |
| 448 | + "--env", "USER=%s" % self._currentUser, |
| 449 | + "--user", str(self._getuid())] |
| 450 | + + self._dockerExtraArgs |
| 451 | + + dockerNetworkStr |
| 452 | + + [self._docker, self._dockerOpenModelicaPath]) |
448 | 453 | elif self._dockerContainer: |
449 | | - omcCommand = ["docker", "exec", "--env", "USER=%s" % self._currentUser, "--user", str(self._getuid())] + self._dockerExtraArgs + [self._dockerContainer, self._dockerOpenModelicaPath] |
| 454 | + omcCommand = (["docker", "exec", |
| 455 | + "--env", "USER=%s" % self._currentUser, |
| 456 | + "--user", str(self._getuid())] |
| 457 | + + self._dockerExtraArgs |
| 458 | + + [self._dockerContainer, self._dockerOpenModelicaPath]) |
450 | 459 | self._dockerCid = self._dockerContainer |
451 | 460 | else: |
452 | 461 | omcCommand = [str(self._get_omc_path())] |
@@ -508,7 +517,8 @@ def _connect_to_omc(self, timeout): |
508 | 517 | time.sleep(timeout / 80.0) |
509 | 518 |
|
510 | 519 | self._port = self._port.replace("0.0.0.0", self._serverIPAddress) |
511 | | - logger.info(f"OMC Server is up and running at {self._omc_zeromq_uri} pid={self._omc_process.pid} cid={self._dockerCid}") |
| 520 | + logger.info(f"OMC Server is up and running at {self._omc_zeromq_uri} " |
| 521 | + f"pid={self._omc_process.pid} cid={self._dockerCid}") |
512 | 522 |
|
513 | 523 | # Create the ZeroMQ socket and connect to OMC server |
514 | 524 | context = zmq.Context.instance() |
|
0 commit comments