Skip to content

Commit 9363202

Browse files
committed
[OMCProcessDocker*] move content to OMCProcessDockerHelper
1 parent c303fd8 commit 9363202

1 file changed

Lines changed: 30 additions & 26 deletions

File tree

OMPython/OMCSession.py

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -601,14 +601,24 @@ def _omc_port_get(self) -> str:
601601

602602
class OMCProcessDockerHelper(OMCProcess):
603603

604-
def __init__(self, **kwargs) -> None:
605-
super().__init__(**kwargs)
604+
def __init__(
605+
self,
606+
timeout: float = 10.00,
607+
dockerExtraArgs: Optional[list] = None,
608+
dockerOpenModelicaPath: str = "omc",
609+
dockerNetwork: Optional[str] = None,
610+
port: Optional[int] = None,
611+
) -> None:
612+
super().__init__(timeout=timeout)
606613

607-
self._dockerExtraArgs: list = []
608-
self._dockerOpenModelicaPath: Optional[str] = None
609-
self._dockerNetwork: Optional[str] = None
614+
if dockerExtraArgs is None:
615+
dockerExtraArgs = []
616+
617+
self._dockerExtraArgs = dockerExtraArgs
618+
self._dockerOpenModelicaPath = dockerOpenModelicaPath
619+
self._dockerNetwork = dockerNetwork
610620

611-
self._interactivePort: Optional[int] = None
621+
self._interactivePort = port
612622

613623
self._dockerCid: Optional[str] = None
614624
self._docker_process: Optional[DummyPopen] = None
@@ -696,22 +706,19 @@ def __init__(
696706
port: Optional[int] = None,
697707
) -> None:
698708

699-
super().__init__(timeout=timeout)
709+
super().__init__(
710+
timeout=timeout,
711+
dockerExtraArgs=dockerExtraArgs,
712+
dockerOpenModelicaPath=dockerOpenModelicaPath,
713+
dockerNetwork=dockerNetwork,
714+
port=port,
715+
)
700716

701717
if docker is None:
702718
raise OMCSessionException("Argument docker must be set!")
703719

704720
self._docker = docker
705721

706-
if dockerExtraArgs is None:
707-
dockerExtraArgs = []
708-
709-
self._dockerExtraArgs = dockerExtraArgs
710-
self._dockerOpenModelicaPath = dockerOpenModelicaPath
711-
self._dockerNetwork = dockerNetwork
712-
713-
self._interactivePort = port
714-
715722
# start up omc executable in docker container waiting for the ZMQ connection
716723
self._omc_process, self._docker_process, self._dockerCid = self._docker_omc_start()
717724
# connect to the running omc instance using ZMQ
@@ -839,22 +846,19 @@ def __init__(
839846
port: Optional[int] = None,
840847
) -> None:
841848

842-
super().__init__(timeout=timeout)
849+
super().__init__(
850+
timeout=timeout,
851+
dockerExtraArgs=dockerExtraArgs,
852+
dockerOpenModelicaPath=dockerOpenModelicaPath,
853+
dockerNetwork=dockerNetwork,
854+
port=port,
855+
)
843856

844857
if not isinstance(dockerContainer, str):
845858
raise OMCSessionException("Argument dockerContainer must be set!")
846859

847860
self._dockerCid = dockerContainer
848861

849-
if dockerExtraArgs is None:
850-
dockerExtraArgs = []
851-
852-
self._dockerExtraArgs = dockerExtraArgs
853-
self._dockerOpenModelicaPath = dockerOpenModelicaPath
854-
self._dockerNetwork = dockerNetwork
855-
856-
self._interactivePort = port
857-
858862
# start up omc executable in docker container waiting for the ZMQ connection
859863
self._omc_process, self._docker_process = self._docker_omc_start()
860864
# connect to the running omc instance using ZMQ

0 commit comments

Comments
 (0)