本文整理汇总了Python中st2actions.runners.ssh.paramiko_ssh.ParamikoSSHClient.CHUNK_SIZE方法的典型用法代码示例。如果您正苦于以下问题:Python ParamikoSSHClient.CHUNK_SIZE方法的具体用法?Python ParamikoSSHClient.CHUNK_SIZE怎么用?Python ParamikoSSHClient.CHUNK_SIZE使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类st2actions.runners.ssh.paramiko_ssh.ParamikoSSHClient
的用法示例。
在下文中一共展示了ParamikoSSHClient.CHUNK_SIZE方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_consume_stderr
# 需要导入模块: from st2actions.runners.ssh.paramiko_ssh import ParamikoSSHClient [as 别名]
# 或者: from st2actions.runners.ssh.paramiko_ssh.ParamikoSSHClient import CHUNK_SIZE [as 别名]
def test_consume_stderr(self):
# Test utf-8 decoding of ``stderr`` 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_stderr_ready.side_effect = [True, True, True, True, False]
chan.recv_stderr.side_effect = ["\xF0", "\x90", "\x8D", "\x88"]
try:
"\xF0".decode("utf-8")
self.fail("Test fixture is not right.")
except UnicodeDecodeError:
pass
stderr = mock._consume_stderr(chan)
self.assertEqual(u"\U00010348", stderr.getvalue())
示例2: test_consume_stderr
# 需要导入模块: from st2actions.runners.ssh.paramiko_ssh import ParamikoSSHClient [as 别名]
# 或者: from st2actions.runners.ssh.paramiko_ssh.ParamikoSSHClient import CHUNK_SIZE [as 别名]
def test_consume_stderr(self):
# Test utf-8 decoding of ``stderr`` 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_stderr_ready.side_effect = [True, True, True, True, False]
chan.recv_stderr.side_effect = ['\xF0', '\x90', '\x8D', '\x88']
try:
'\xF0'.decode('utf-8')
self.fail('Test fixture is not right.')
except UnicodeDecodeError:
pass
stderr = mock._consume_stderr(chan)
self.assertEqual(u'\U00010348', stderr.getvalue())