本文整理汇总了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()
示例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