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


Python ParallelSSHClient.finished方法代码示例

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


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

示例1: test_pssh_client_hosts_list_part_failure

# 需要导入模块: from pssh import ParallelSSHClient [as 别名]
# 或者: from pssh.ParallelSSHClient import finished [as 别名]
 def test_pssh_client_hosts_list_part_failure(self):
     """Test getting output for remainder of host list in the case where one
     host in the host list has a failure"""
     server2_socket = make_socket('127.0.0.2', port=self.listen_port)
     server2_port = server2_socket.getsockname()[1]
     server2 = start_server(server2_socket, fail_auth=True)
     hosts = [self.host, '127.0.0.2']
     client = ParallelSSHClient(hosts,
                                port=self.listen_port,
                                pkey=self.user_key,
                                agent=self.agent)
     output = client.run_command(self.fake_cmd,
                                 stop_on_errors=False)
     self.assertFalse(client.finished(output))
     client.join(output)
     self.assertTrue(client.finished(output))
     self.assertTrue(hosts[0] in output,
                     msg="Successful host does not exist in output - output is %s" % (output,))
     self.assertTrue(hosts[1] in output,
                     msg="Failed host does not exist in output - output is %s" % (output,))
     self.assertTrue('exception' in output[hosts[1]],
                     msg="Failed host %s has no exception in output - %s" % (hosts[1], output,))
     try:
         raise output[hosts[1]]['exception']
     except AuthenticationException:
         pass
     else:
         raise Exception("Expected AuthenticationException, got %s instead" % (
             output[hosts[1]]['exception'],))
     del client
     server2.kill()
开发者ID:,项目名称:,代码行数:33,代码来源:

示例2: test_pssh_client_long_running_command_exit_codes

# 需要导入模块: from pssh import ParallelSSHClient [as 别名]
# 或者: from pssh.ParallelSSHClient import finished [as 别名]
 def test_pssh_client_long_running_command_exit_codes(self):
     expected_lines = 5
     client = ParallelSSHClient([self.host], port=self.listen_port,
                                pkey=self.user_key)
     output = client.run_command(self.long_cmd(expected_lines))
     self.assertTrue(self.host in output, msg="Got no output for command")
     self.assertTrue(not output[self.host]['exit_code'],
                     msg="Got exit code %s for still running cmd.." % (
                         output[self.host]['exit_code'],))
     self.assertFalse(client.finished(output))
     # Embedded server is also asynchronous and in the same thread
     # as our client so need to sleep for duration of server connection
     gevent.sleep(expected_lines)
     client.join(output)
     self.assertTrue(client.finished(output))
     self.assertTrue(output[self.host]['exit_code'] == 0,
                     msg="Got non-zero exit code %s" % (
                         output[self.host]['exit_code'],))
     del client
开发者ID:,项目名称:,代码行数:21,代码来源:


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