def check_output(self, command, input_data=None, stderr=sys.stderr):
logger.debug('Running "%s"', command)
ssh_stdin, ssh_stdout, ssh_stderr = self.exec_command(command)
if input_data is not None:
ssh_stdin.write(input_data)
exit_code = ssh_stdout.channel.recv_exit_status()
stderr.write(ssh_stderr.read().decode("utf-8"))
if exit_code != os.EX_OK:
raise Exception('Error while running "{}": {}'.format(command, os.errno.errorcode.get(exit_code)))
return ssh_stdout.read().decode("utf-8")
评论列表
文章目录