__init__.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:worker 作者: mechaphish 项目源码 文件源码
def execute(self, command):
        assert self.ssh is not None

        environment = " ".join("{}='{}'".format(k, v) for k, v in os.environ.items()
                               if k.startswith("POSTGRES"))
        env_command = "{} {}".format(environment, command)
        LOG.debug("Executing command: %s", env_command)
        stdout_content = None
        stderr_content = None
        try:
            _, stdout, stderr = self.ssh.exec_command(env_command)
            exit_status = stdout.channel.recv_exit_status()
            if exit_status != 0:
                raise paramiko.SSHException("'%s' failed with exit status %d", command, exit_status)
            stdout_content = stdout.read()
            stderr_content = stderr.read()
        except paramiko.SSHException as e:
            LOG.error("Unable to excute command '%s' on host: %s", command, e)
            LOG.debug("stdout: %s", stdout.read())
            LOG.debug("stderr: %s", stderr.read())
            raise e
        return stdout_content, stderr_content
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号