experiment.py 文件源码

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

项目:pydsef 作者: DSEF 项目源码 文件源码
def exec_command(self, cmd, block = True):
        """Executes a command on the master node. If block is True, wait until command finishes and return stdout,
        otherwise exit immediately and return (stdin, stdout, stderr)"""
        if self.client == None:
            self.client = ssh.SSHClient()
            self.client.load_system_host_keys()
            self.client.set_missing_host_key_policy(ssh.WarningPolicy)
            self.client.connect(self.hostname, username = self.username)

            self.exec_command('mkdir -p dsef')

        (stdin, stdout, stderr) = self.client.exec_command("cd ~/{} && {}".format(self.dist_sys, cmd), get_pty = True)
        if block:
            return str(stdout.read(), 'ascii')
        else:
            return (stdin, stdout, stderr)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号