本文整理汇总了Python中st2actions.runners.ssh.paramiko_ssh.ParamikoSSHClient._consume_stdout方法的典型用法代码示例。如果您正苦于以下问题:Python ParamikoSSHClient._consume_stdout方法的具体用法?Python ParamikoSSHClient._consume_stdout怎么用?Python ParamikoSSHClient._consume_stdout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类st2actions.runners.ssh.paramiko_ssh.ParamikoSSHClient
的用法示例。
在下文中一共展示了ParamikoSSHClient._consume_stdout方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_consume_stdout
# 需要导入模块: from st2actions.runners.ssh.paramiko_ssh import ParamikoSSHClient [as 别名]
# 或者: from st2actions.runners.ssh.paramiko_ssh.ParamikoSSHClient import _consume_stdout [as 别名]
def test_consume_stdout(self):
# Test utf-8 decoding of ``stdout`` still works fine when reading CHUNK_SIZE splits a
# multi-byte utf-8 character in the middle. We should wait to collect all bytes
# and finally decode.
conn_params = {"hostname": "dummy.host.org", "username": "ubuntu"}
mock = ParamikoSSHClient(**conn_params)
mock.CHUNK_SIZE = 1
chan = Mock()
chan.recv_ready.side_effect = [True, True, True, True, False]
chan.recv.side_effect = ["\xF0", "\x90", "\x8D", "\x88"]
try:
"\xF0".decode("utf-8")
self.fail("Test fixture is not right.")
except UnicodeDecodeError:
pass
stdout = mock._consume_stdout(chan)
self.assertEqual(u"\U00010348", stdout.getvalue())
示例2: test_consume_stdout
# 需要导入模块: from st2actions.runners.ssh.paramiko_ssh import ParamikoSSHClient [as 别名]
# 或者: from st2actions.runners.ssh.paramiko_ssh.ParamikoSSHClient import _consume_stdout [as 别名]
def test_consume_stdout(self):
# Test utf-8 decoding of ``stdout`` still works fine when reading CHUNK_SIZE splits a
# multi-byte utf-8 character in the middle. We should wait to collect all bytes
# and finally decode.
conn_params = {'hostname': 'dummy.host.org',
'username': 'ubuntu'}
mock = ParamikoSSHClient(**conn_params)
mock.CHUNK_SIZE = 1
chan = Mock()
chan.recv_ready.side_effect = [True, True, True, True, False]
chan.recv.side_effect = ['\xF0', '\x90', '\x8D', '\x88']
try:
'\xF0'.decode('utf-8')
self.fail('Test fixture is not right.')
except UnicodeDecodeError:
pass
stdout = mock._consume_stdout(chan)
self.assertEqual(u'\U00010348', stdout.getvalue())