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


Python BufferedPipe.read方法代码示例

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


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

示例1: test_2_delay

# 需要导入模块: from paramiko.buffered_pipe import BufferedPipe [as 别名]
# 或者: from paramiko.buffered_pipe.BufferedPipe import read [as 别名]
 def test_2_delay(self):
     p = BufferedPipe()
     self.assert_(not p.read_ready())
     threading.Thread(target=delay_thread, args=(p,)).start()
     self.assertEquals('a', p.read(1, 0.1))
     try:
         p.read(1, 0.1)
         self.assert_(False)
     except PipeTimeout:
         pass
     self.assertEquals('b', p.read(1, 1.0))
     self.assertEquals('', p.read(1))
开发者ID:AloneRoad,项目名称:Football-Info,代码行数:14,代码来源:test_buffered_pipe.py

示例2: test_1_buffered_pipe

# 需要导入模块: from paramiko.buffered_pipe import BufferedPipe [as 别名]
# 或者: from paramiko.buffered_pipe.BufferedPipe import read [as 别名]
 def test_1_buffered_pipe(self):
     p = BufferedPipe()
     self.assert_(not p.read_ready())
     p.feed('hello.')
     self.assert_(p.read_ready())
     data = p.read(6)
     self.assertEquals('hello.', data)
     
     p.feed('plus/minus')
     self.assertEquals('plu', p.read(3))
     self.assertEquals('s/m', p.read(3))
     self.assertEquals('inus', p.read(4))
     
     p.close()
     self.assert_(not p.read_ready())
     self.assertEquals('', p.read(1))
开发者ID:AloneRoad,项目名称:Football-Info,代码行数:18,代码来源:test_buffered_pipe.py

示例3: test_1_buffered_pipe

# 需要导入模块: from paramiko.buffered_pipe import BufferedPipe [as 别名]
# 或者: from paramiko.buffered_pipe.BufferedPipe import read [as 别名]
    def test_1_buffered_pipe(self):
        p = BufferedPipe()
        self.assertTrue(not p.read_ready())
        p.feed("hello.")
        self.assertTrue(p.read_ready())
        data = p.read(6)
        self.assertEqual(b"hello.", data)

        p.feed("plus/minus")
        self.assertEqual(b"plu", p.read(3))
        self.assertEqual(b"s/m", p.read(3))
        self.assertEqual(b"inus", p.read(4))

        p.close()
        self.assertTrue(not p.read_ready())
        self.assertEqual(b"", p.read(1))
开发者ID:gaudenz,项目名称:paramiko,代码行数:18,代码来源:test_buffered_pipe.py

示例4: Channel

# 需要导入模块: from paramiko.buffered_pipe import BufferedPipe [as 别名]
# 或者: from paramiko.buffered_pipe.BufferedPipe import read [as 别名]
class Channel (ClosingContextManager):
    """
    A secure tunnel across an SSH `.Transport`.  A Channel is meant to behave
    like a socket, and has an API that should be indistinguishable from the
    Python socket API.

    Because SSH2 has a windowing kind of flow control, if you stop reading data
    from a Channel and its buffer fills up, the server will be unable to send
    you any more data until you read some of it.  (This won't affect other
    channels on the same transport -- all channels on a single transport are
    flow-controlled independently.)  Similarly, if the server isn't reading
    data you send, calls to `send` may block, unless you set a timeout.  This
    is exactly like a normal network socket, so it shouldn't be too surprising.
    
    Instances of this class may be used as context managers.
    """

    def __init__(self, chanid):
        """
        Create a new channel.  The channel is not associated with any
        particular session or `.Transport` until the Transport attaches it.
        Normally you would only call this method from the constructor of a
        subclass of `.Channel`.

        :param int chanid:
            the ID of this channel, as passed by an existing `.Transport`.
        """
        self.chanid = chanid
        self.remote_chanid = 0
        self.transport = None
        self.active = False
        self.eof_received = 0
        self.eof_sent = 0
        self.in_buffer = BufferedPipe()
        self.in_stderr_buffer = BufferedPipe()
        self.timeout = None
        self.closed = False
        self.ultra_debug = False
        self.lock = threading.Lock()
        self.out_buffer_cv = threading.Condition(self.lock)
        self.in_window_size = 0
        self.out_window_size = 0
        self.in_max_packet_size = 0
        self.out_max_packet_size = 0
        self.in_window_threshold = 0
        self.in_window_sofar = 0
        self.status_event = threading.Event()
        self._name = str(chanid)
        self.logger = util.get_logger('paramiko.transport')
        self._pipe = None
        self.event = threading.Event()
        self.event_ready = False
        self.combine_stderr = False
        self.exit_status = -1
        self.origin_addr = None

    def __del__(self):
        try:
            self.close()
        except:
            pass

    def __repr__(self):
        """
        Return a string representation of this object, for debugging.
        """
        out = '<paramiko.Channel %d' % self.chanid
        if self.closed:
            out += ' (closed)'
        elif self.active:
            if self.eof_received:
                out += ' (EOF received)'
            if self.eof_sent:
                out += ' (EOF sent)'
            out += ' (open) window=%d' % self.out_window_size
            if len(self.in_buffer) > 0:
                out += ' in-buffer=%d' % (len(self.in_buffer),)
        out += ' -> ' + repr(self.transport)
        out += '>'
        return out

    @open_only
    def get_pty(self, term='vt100', width=80, height=24, width_pixels=0,
                height_pixels=0):
        """
        Request a pseudo-terminal from the server.  This is usually used right
        after creating a client channel, to ask the server to provide some
        basic terminal semantics for a shell invoked with `invoke_shell`.
        It isn't necessary (or desirable) to call this method if you're going
        to exectue a single command with `exec_command`.

        :param str term: the terminal type to emulate (for example, ``'vt100'``)
        :param int width: width (in characters) of the terminal screen
        :param int height: height (in characters) of the terminal screen
        :param int width_pixels: width (in pixels) of the terminal screen
        :param int height_pixels: height (in pixels) of the terminal screen

        :raises SSHException:
            if the request was rejected or the channel was closed
        """
#.........这里部分代码省略.........
开发者ID:steffentemplin,项目名称:paramiko,代码行数:103,代码来源:channel.py

示例5: test_3_close_while_reading

# 需要导入模块: from paramiko.buffered_pipe import BufferedPipe [as 别名]
# 或者: from paramiko.buffered_pipe.BufferedPipe import read [as 别名]
 def test_3_close_while_reading(self):
     p = BufferedPipe()
     threading.Thread(target=close_thread, args=(p,)).start()
     data = p.read(1, 1.0)
     self.assertEquals('', data)
开发者ID:AloneRoad,项目名称:Football-Info,代码行数:7,代码来源:test_buffered_pipe.py

示例6: Channel

# 需要导入模块: from paramiko.buffered_pipe import BufferedPipe [as 别名]
# 或者: from paramiko.buffered_pipe.BufferedPipe import read [as 别名]
class Channel (object):
    """
    A secure tunnel across an SSH L{Transport}.  A Channel is meant to behave
    like a socket, and has an API that should be indistinguishable from the
    python socket API.

    Because SSH2 has a windowing kind of flow control, if you stop reading data
    from a Channel and its buffer fills up, the server will be unable to send
    you any more data until you read some of it.  (This won't affect other
    channels on the same transport -- all channels on a single transport are
    flow-controlled independently.)  Similarly, if the server isn't reading
    data you send, calls to L{send} may block, unless you set a timeout.  This
    is exactly like a normal network socket, so it shouldn't be too surprising.
    """

    def __init__(self, chanid):
        """
        Create a new channel.  The channel is not associated with any
        particular session or L{Transport} until the Transport attaches it.
        Normally you would only call this method from the constructor of a
        subclass of L{Channel}.

        @param chanid: the ID of this channel, as passed by an existing
            L{Transport}.
        @type chanid: int
        """
        self.chanid = chanid
        self.remote_chanid = 0
        self.transport = None
        self.active = False
        self.eof_received = 0
        self.eof_sent = 0
        self.in_buffer = BufferedPipe()
        self.in_stderr_buffer = BufferedPipe()
        self.timeout = None
        self.closed = False
        self.ultra_debug = False
        self.lock = threading.Lock()
        self.out_buffer_cv = threading.Condition(self.lock)
        self.in_window_size = 0
        self.out_window_size = 0
        self.in_max_packet_size = 0
        self.out_max_packet_size = 0
        self.in_window_threshold = 0
        self.in_window_sofar = 0
        self.status_event = threading.Event()
        self._name = str(chanid)
        self.logger = util.get_logger('paramiko.transport')
        self._pipe = None
        self.event = threading.Event()
        self.combine_stderr = False
        self.exit_status = -1
        self.origin_addr = None
    
    def __del__(self):
        try:
            self.close()
        except:
            pass
        
    def __repr__(self):
        """
        Return a string representation of this object, for debugging.

        @rtype: str
        """
        out = '<paramiko.Channel %d' % self.chanid
        if self.closed:
            out += ' (closed)'
        elif self.active:
            if self.eof_received:
                out += ' (EOF received)'
            if self.eof_sent:
                out += ' (EOF sent)'
            out += ' (open) window=%d' % (self.out_window_size)
            if len(self.in_buffer) > 0:
                out += ' in-buffer=%d' % (len(self.in_buffer),)
        out += ' -> ' + repr(self.transport)
        out += '>'
        return out

    def get_pty(self, term='vt100', width=80, height=24):
        """
        Request a pseudo-terminal from the server.  This is usually used right
        after creating a client channel, to ask the server to provide some
        basic terminal semantics for a shell invoked with L{invoke_shell}.
        It isn't necessary (or desirable) to call this method if you're going
        to exectue a single command with L{exec_command}.

        @param term: the terminal type to emulate (for example, C{'vt100'})
        @type term: str
        @param width: width (in characters) of the terminal screen
        @type width: int
        @param height: height (in characters) of the terminal screen
        @type height: int
        
        @raise SSHException: if the request was rejected or the channel was
            closed
        """
        if self.closed or self.eof_received or self.eof_sent or not self.active:
#.........这里部分代码省略.........
开发者ID:myelin,项目名称:bbm-tools,代码行数:103,代码来源:channel.py

示例7: Channel

# 需要导入模块: from paramiko.buffered_pipe import BufferedPipe [as 别名]
# 或者: from paramiko.buffered_pipe.BufferedPipe import read [as 别名]
class Channel (object):
    """
    A secure tunnel across an SSH `.Transport`.  A Channel is meant to behave
    like a socket, and has an API that should be indistinguishable from the
    Python socket API.

    Because SSH2 has a windowing kind of flow control, if you stop reading data
    from a Channel and its buffer fills up, the server will be unable to send
    you any more data until you read some of it.  (This won't affect other
    channels on the same transport -- all channels on a single transport are
    flow-controlled independently.)  Similarly, if the server isn't reading
    data you send, calls to `send` may block, unless you set a timeout.  This
    is exactly like a normal network socket, so it shouldn't be too surprising.
    """

    def __init__(self, chanid):
        """
        Create a new channel.  The channel is not associated with any
        particular session or `.Transport` until the Transport attaches it.
        Normally you would only call this method from the constructor of a
        subclass of `.Channel`.

        :param int chanid:
            the ID of this channel, as passed by an existing `.Transport`.
        """
        self.chanid = chanid
        self.remote_chanid = 0
        self.transport = None
        self.active = False
        self.eof_received = 0
        self.eof_sent = 0
        self.in_buffer = BufferedPipe()
        self.in_stderr_buffer = BufferedPipe()
        self.timeout = None
        self.closed = False
        self.ultra_debug = False
        self.lock = threading.Lock()
        self.out_buffer_cv = threading.Condition(self.lock)
        self.in_window_size = 0
        self.out_window_size = 0
        self.in_max_packet_size = 0
        self.out_max_packet_size = 0
        self.in_window_threshold = 0
        self.in_window_sofar = 0
        self.status_event = threading.Event()
        self._name = str(chanid)
        self.logger = util.get_logger('paramiko.transport')
        self._pipe = None
        self.event = threading.Event()
        self.event_ready = False
        self.combine_stderr = False
        self.exit_status = -1
        self.origin_addr = None
    
    def __del__(self):
        try:
            self.close()
        except:
            pass
        
    def __repr__(self):
        """
        Return a string representation of this object, for debugging.
        """
        out = '<paramiko.Channel %d' % self.chanid
        if self.closed:
            out += ' (closed)'
        elif self.active:
            if self.eof_received:
                out += ' (EOF received)'
            if self.eof_sent:
                out += ' (EOF sent)'
            out += ' (open) window=%d' % (self.out_window_size)
            if len(self.in_buffer) > 0:
                out += ' in-buffer=%d' % (len(self.in_buffer),)
        out += ' -> ' + repr(self.transport)
        out += '>'
        return out

    def get_pty(self, term='vt100', width=80, height=24, width_pixels=0,
                height_pixels=0):
        """
        Request a pseudo-terminal from the server.  This is usually used right
        after creating a client channel, to ask the server to provide some
        basic terminal semantics for a shell invoked with `invoke_shell`.
        It isn't necessary (or desirable) to call this method if you're going
        to exectue a single command with `exec_command`.

        :param str term: the terminal type to emulate (for example, ``'vt100'``)
        :param int width: width (in characters) of the terminal screen
        :param int height: height (in characters) of the terminal screen
        :param int width_pixels: width (in pixels) of the terminal screen
        :param int height_pixels: height (in pixels) of the terminal screen
        
        :raises SSHException:
            if the request was rejected or the channel was closed
        """
        if self.closed or self.eof_received or self.eof_sent or not self.active:
            raise SSHException('Channel is not open')
        m = Message()
#.........这里部分代码省略.........
开发者ID:bandrel,项目名称:paramiko,代码行数:103,代码来源:channel.py

示例8: Channel

# 需要导入模块: from paramiko.buffered_pipe import BufferedPipe [as 别名]
# 或者: from paramiko.buffered_pipe.BufferedPipe import read [as 别名]
class Channel(object):
    """
    A secure tunnel across an SSH L{Transport}.  A Channel is meant to behave
    like a socket, and has an API that should be indistinguishable from the
    python socket API.

    Because SSH2 has a windowing kind of flow control, if you stop reading data
    from a Channel and its buffer fills up, the server will be unable to send
    you any more data until you read some of it.  (This won't affect other
    channels on the same transport -- all channels on a single transport are
    flow-controlled independently.)  Similarly, if the server isn't reading
    data you send, calls to L{send} may block, unless you set a timeout.  This
    is exactly like a normal network socket, so it shouldn't be too surprising.
    """

    def __init__(self, chanid):
        """
        Create a new channel.  The channel is not associated with any
        particular session or L{Transport} until the Transport attaches it.
        Normally you would only call this method from the constructor of a
        subclass of L{Channel}.

        @param chanid: the ID of this channel, as passed by an existing
            L{Transport}.
        @type chanid: int
        """
        self.chanid = chanid
        self.remote_chanid = 0
        self.transport = None
        self.active = False
        self.eof_received = 0
        self.eof_sent = 0
        self.in_buffer = BufferedPipe()
        self.in_stderr_buffer = BufferedPipe()
        self.timeout = None
        self.closed = False
        self.ultra_debug = False
        self.lock = threading.Lock()
        self.out_buffer_cv = threading.Condition(self.lock)
        self.in_window_size = 0
        self.out_window_size = 0
        self.in_max_packet_size = 0
        self.out_max_packet_size = 0
        self.in_window_threshold = 0
        self.in_window_sofar = 0
        self.status_event = threading.Event()
        self._name = str(chanid)
        self.logger = util.get_logger("paramiko.transport")
        self._pipe = None
        self.event = threading.Event()
        self.event_ready = False
        self.combine_stderr = False
        self.exit_status = -1
        self.origin_addr = None

    def __del__(self):
        try:
            self.close()
        except:
            pass

    def __repr__(self):
        """
        Return a string representation of this object, for debugging.

        @rtype: str
        """
        out = "<paramiko.Channel %d" % self.chanid
        if self.closed:
            out += " (closed)"
        elif self.active:
            if self.eof_received:
                out += " (EOF received)"
            if self.eof_sent:
                out += " (EOF sent)"
            out += " (open) window=%d" % (self.out_window_size)
            if len(self.in_buffer) > 0:
                out += " in-buffer=%d" % (len(self.in_buffer),)
        out += " -> " + repr(self.transport)
        out += ">"
        return out

    def get_pty(self, term="vt100", width=80, height=24):
        """
        Request a pseudo-terminal from the server.  This is usually used right
        after creating a client channel, to ask the server to provide some
        basic terminal semantics for a shell invoked with L{invoke_shell}.
        It isn't necessary (or desirable) to call this method if you're going
        to exectue a single command with L{exec_command}.

        @param term: the terminal type to emulate (for example, C{'vt100'})
        @type term: str
        @param width: width (in characters) of the terminal screen
        @type width: int
        @param height: height (in characters) of the terminal screen
        @type height: int

        @raise SSHException: if the request was rejected or the channel was
            closed
        """
#.........这里部分代码省略.........
开发者ID:StefanKjartansson,项目名称:paramiko,代码行数:103,代码来源:channel.py


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