示例#1
0
    def run(
        self,
        cmd,
        timeout=120,
        exit_on_fail=False,
        port_forward=None,
        with_output=False,
        environment_variables: Dict[str, object] = None,
        run_env="auto",
        ssh_options_override_ssh_key="",
    ):
        if run_env == "auto":
            run_env = "host" if cmd.find("docker") == 0 else "docker"

        if environment_variables:
            cmd = _with_environment_variables(cmd, environment_variables)

        if run_env == "docker":
            cmd = self._docker_expand_user(cmd, any_char=True)
            cmd = " ".join(_with_interactive(cmd))
            cmd = with_docker_exec([cmd],
                                   container_name=self.container_name,
                                   with_interactive=True)[0]

        if self.shutdown:
            cmd += "; sudo shutdown -h now"
        return self.ssh_command_runner.run(
            cmd,
            timeout=timeout,
            exit_on_fail=exit_on_fail,
            port_forward=port_forward,
            with_output=with_output,
            ssh_options_override_ssh_key=ssh_options_override_ssh_key)
示例#2
0
    def run(self,
            cmd,
            timeout=120,
            exit_on_fail=False,
            port_forward=None,
            with_output=False,
            run_env=True,
            ssh_options_override=None,
            **kwargs):
        if run_env == "auto":
            run_env = "host" if cmd.find("docker") == 0 else "docker"

        if run_env == "docker":
            cmd = self._docker_expand_user(cmd, any_char=True)
            cmd = " ".join(_with_interactive(cmd))
            cmd = with_docker_exec([cmd],
                                   container_name=self.docker_name,
                                   with_interactive=True)[0]

        if self.shutdown:
            cmd += "; sudo shutdown -h now"
        return self.ssh_command_runner.run(
            cmd,
            timeout=timeout,
            exit_on_fail=exit_on_fail,
            port_forward=port_forward,
            with_output=with_output,
            ssh_options_override=ssh_options_override)
示例#3
0
文件: commands.py 项目: aniryou/ray
 def wrap_docker(command):
     container_name = config["docker"]["container_name"]
     if not container_name:
         raise ValueError("Docker container not specified in config.")
     return with_docker_exec(
         [command], container_name=container_name)[0]
示例#4
0
 def wrap_docker(command):
     container_name = config["docker"]["container_name"]
     if not container_name:
         raise ValueError("Docker container not specified in config.")
     return with_docker_exec(
         [command], container_name=container_name)[0]