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


Python ParamikoSSHClient._consume_stdout方法代码示例

本文整理汇总了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())
开发者ID:rlugojr,项目名称:st2,代码行数:20,代码来源:test_paramiko_ssh.py

示例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())
开发者ID:AlexeyDeyneko,项目名称:st2,代码行数:21,代码来源:test_paramiko_ssh.py


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