当前位置: 首页>>代码示例>>Python>>正文


Python ParallelSSHClient.get_output方法代码示例

本文整理汇总了Python中pssh.ParallelSSHClient.get_output方法的典型用法代码示例。如果您正苦于以下问题:Python ParallelSSHClient.get_output方法的具体用法?Python ParallelSSHClient.get_output怎么用?Python ParallelSSHClient.get_output使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pssh.ParallelSSHClient的用法示例。


在下文中一共展示了ParallelSSHClient.get_output方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_pssh_client_run_command_get_output_explicit

# 需要导入模块: from pssh import ParallelSSHClient [as 别名]
# 或者: from pssh.ParallelSSHClient import get_output [as 别名]
 def test_pssh_client_run_command_get_output_explicit(self):
     client = ParallelSSHClient([self.host], port=self.listen_port,
                                pkey=self.user_key)
     out = client.run_command(self.fake_cmd)
     cmds = [cmd for host in out for cmd in [out[host]['cmd']]]
     output = {}
     for cmd in cmds:
         client.get_output(cmd, output)
     expected_exit_code = 0
     expected_stdout = [self.fake_resp]
     expected_stderr = []
     stdout = list(output[self.host]['stdout'])
     stderr = list(output[self.host]['stderr'])
     exit_code = output[self.host]['exit_code']
     self.assertEqual(expected_exit_code, exit_code,
                      msg="Got unexpected exit code - %s, expected %s" %
                      (exit_code,
                       expected_exit_code,))
     self.assertEqual(expected_stdout, stdout,
                      msg="Got unexpected stdout - %s, expected %s" % 
                      (stdout,
                       expected_stdout,))
     self.assertEqual(expected_stderr, stderr,
                      msg="Got unexpected stderr - %s, expected %s" % 
                      (stderr,
                       expected_stderr,))
     del client
开发者ID:bentsi,项目名称:parallel-ssh,代码行数:29,代码来源:test_pssh_client.py

示例2: test_pssh_client_run_command_get_output_explicit

# 需要导入模块: from pssh import ParallelSSHClient [as 别名]
# 或者: from pssh.ParallelSSHClient import get_output [as 别名]
 def test_pssh_client_run_command_get_output_explicit(self):
     server = start_server({ self.fake_cmd : self.fake_resp },
                           self.listen_socket)
     client = ParallelSSHClient(['127.0.0.1'], port=self.listen_port,
                                pkey=self.user_key)
     out = client.run_command(self.fake_cmd)
     cmds = [cmd for host in out for cmd in [out[host]['cmd']]]
     output = client.get_output(commands=cmds)
     expected_exit_code = 0
     expected_stdout = [self.fake_resp]
     expected_stderr = []
     exit_code = output['127.0.0.1']['exit_code']
     stdout = list(output['127.0.0.1']['stdout'])
     stderr = list(output['127.0.0.1']['stderr'])
     self.assertEqual(expected_exit_code, exit_code,
                      msg="Got unexpected exit code - %s, expected %s" %
                      (exit_code,
                       expected_exit_code,))
     self.assertEqual(expected_stdout, stdout,
                      msg="Got unexpected stdout - %s, expected %s" % 
                      (stdout,
                       expected_stdout,))
     self.assertEqual(expected_stderr, stderr,
                      msg="Got unexpected stderr - %s, expected %s" % 
                      (stderr,
                       expected_stderr,))
     del client
     server.join()
开发者ID:Element-s,项目名称:parallel-ssh,代码行数:30,代码来源:test_pssh_client.py


注:本文中的pssh.ParallelSSHClient.get_output方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。