(self, files: Iterable[str])
return result
Run the Docker command
Run the Docker command
Run the Docker command
def run_container(self, files: Iterable[str]) -> subprocess.CompletedProcess:
        """
        Run the Docker command
        """
        targets: Iterable[Path] = [Path(p) for p in files]
        command = self.docker_command
        is_remote = self.use_remote_docker
        expanded = {t: str(t.relative_to(self.base_path)) for t in targets}

        container = self._create_container(expanded.values())

        if is_remote:
            self._setup_remote_docker(container, expanded)

        # Python docker does not allow -a, so use subprocess.run
        result = subprocess.run(
            ["docker", "start", "-a", str(container.id)],
            encoding="utf-8",
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
        )

        logging.info(
            f"{self.tool_id()}: Returned code {result.returncode} with stdout[:4000]:\n"
            f"{result.stdout[:4000]}\nstderr[:4000]\n{result.stderr[:4000]}"
        )

        if not self.is_allowed_returncode(result.returncode):
            raise subprocess.CalledProcessError(
                cmd=command,
                returncode=result.returncode,
                output=result.stdout,
                stderr=result.stderr,
            )

        return result
def run_container ( self , files : Iterable [ str ] ) -> subprocess . CompletedProcess : targets : Iterable [ Path ] = [ Path ( p ) for p in files ] command = self . docker_command is_remote = self . use_remote_docker expanded = { t : str ( t . relative_to ( self . base_path ) ) for t in targets } container = self . _create_container ( expanded . values ( ) ) if is_remote : self . _setup_remote_docker ( container , expanded ) # Python docker does not allow -a, so use subprocess.run result = subprocess . run ( [ "docker" , "start" , "-a" , str ( container . id ) ] , encoding = "utf-8" , stdout = subprocess . PIPE , stderr = subprocess . PIPE , ) logging . info ( f"{self.tool_id()}: Returned code {result.returncode} with stdout[:4000]:\n" f"{result.stdout[:4000]}\nstderr[:4000]\n{result.stderr[:4000]}" ) if not self . is_allowed_returncode ( result . returncode ) : raise subprocess . CalledProcessError ( cmd = command , returncode = result . returncode , output = result . stdout , stderr = result . stderr , ) return result