| 35 | |
| 36 | |
| 37 | class DockerExecutorBase(ABC): |
| 38 | def __init__(self): |
| 39 | self.docker_cmd = self._initialize_docker_cmd() |
| 40 | self.executor = WindowsExecutor() if platform.system() == 'Windows' else UnixExecutor() |
| 41 | |
| 42 | @abstractmethod |
| 43 | async def run_command(self, command: str, *args) -> Tuple[int, str, str]: |
| 44 | pass |
| 45 | |
| 46 | def _initialize_docker_cmd(self) -> str: |
| 47 | if platform.system() == 'Windows': |
| 48 | docker_dir = r"C:\Program Files\Docker\Docker\resources\bin" |
| 49 | docker_paths = [ |
| 50 | os.path.join(docker_dir, "docker-compose.exe"), |
| 51 | os.path.join(docker_dir, "docker.exe") |
| 52 | ] |
| 53 | for path in docker_paths: |
| 54 | if os.path.exists(path): |
| 55 | return path |
| 56 | |
| 57 | docker_cmd = shutil.which('docker') |
| 58 | if not docker_cmd: |
| 59 | raise RuntimeError("Docker executable not found") |
| 60 | return docker_cmd |
| 61 | |
| 62 | |
| 63 | class DockerComposeExecutor(DockerExecutorBase): |
nothing calls this directly
no outgoing calls
no test coverage detected