コード例 #1
0
ファイル: server.py プロジェクト: larbing/pants
    def __init__(self, *args, **kwargs):
        Stream.__init__(self, *args, **kwargs)

        # Request State Storage
        self.current_request = None
        self._finished = False

        # Read the initial request.
        self._await_request()
コード例 #2
0
    def __init__(self, *args, **kwargs):
        Stream.__init__(self, *args, **kwargs)

        # Request State Storage
        self.current_request = None
        self._finished = False

        # Read the initial request.
        self._await_request()
コード例 #3
0
ファイル: test_stream.py プロジェクト: apt-shansen/pants
 def test_stream_set_read_delimiter_invalid_value(self):
     # not a great test, given that the error needs to be raised
     # with any non-valid type, not just with a list
     stream = Stream()
     passed = False
     try:
         stream.read_delimiter = []
     except TypeError:
         passed = True
     self.assertTrue(passed)
コード例 #4
0
 def test_stream_set_read_delimiter_invalid_value(self):
     # not a great test, given that the error needs to be raised
     # with any non-valid type, not just with a list
     stream = Stream()
     passed = False
     try:
         stream.read_delimiter = []
     except TypeError:
         passed = True
     self.assertTrue(passed)
コード例 #5
0
    def __init__(self, encoding='utf-8', **kwargs):
        Stream.__init__(self, **kwargs)

        # Set our prefix to an empty string. This is prepended to all sent
        # commands, and useful for servers.
        self.prefix = ''
        self.encoding = encoding

        # Read lines at once.
        self.read_delimiter = '\n'
コード例 #6
0
    def connect(self, server=None, port=None):
        """
        Connect to the server.

        =========  ============
        Argument   Description
        =========  ============
        server     The host to connect to.
        port       The port to connect to on the remote server.
        =========  ============
        """
        if not self.connected and not self.connecting:
            if server:
                self._server = server
            if port:
                self._port = port


        Stream.connect(self, (self._server, self._port))
コード例 #7
0
ファイル: unix.py プロジェクト: ixokai/pants
    def connect(self, addr):
        """
        Connect the channel to a remote Unix socket.

        Returns the channel.

        ==========  ============
        Arguments   Description
        ==========  ============
        addr        The address to connect to.
        ==========  ============
        """
        return Stream.connect(self, addr)
コード例 #8
0
ファイル: network.py プロジェクト: ixokai/pants
    def connect(self, host, port):
        """
        Connect the channel to a remote socket.

        Returns the channel.

        ==========  ============
        Arguments   Description
        ==========  ============
        host        The remote host to connect to.
        port        The port to connect on.
        ==========  ============
        """
        return Stream.connect(self, (host, port))
コード例 #9
0
    def test_stream_handle_read_event_processes_recv_buffer_before_closing(
            self):
        # to ensure we don't reintroduce issue #41
        stream = Stream()
        stream._socket_recv = MagicMock(return_value=None)

        manager = MagicMock()
        stream._process_recv_buffer = manager._process_recv_buffer
        stream.close = manager.close

        stream._handle_read_event()

        expected_calls = [call._process_recv_buffer(), call.close(flush=False)]
        self.assertTrue(manager.mock_calls == expected_calls)
コード例 #10
0
ファイル: test_stream.py プロジェクト: larbing/pants
    def test_stream_handle_read_event_processes_recv_buffer_before_closing(self):
        # to ensure we don't reintroduce issue #41
        stream = Stream()
        stream._socket_recv = MagicMock(return_value=None)

        manager = MagicMock()
        stream._process_recv_buffer = manager._process_recv_buffer
        stream.close = manager.close

        stream._handle_read_event()

        expected_calls = [call._process_recv_buffer(), call.close(flush=False)]
        self.assertTrue(manager.mock_calls == expected_calls)
コード例 #11
0
ファイル: dns.py プロジェクト: ixokai/pants
    def __init__(self, resolver, id, **kwargs):
        Stream.__init__(self, **kwargs)
        self.resolver = resolver
        self.id = id

        self.response = ""
コード例 #12
0
ファイル: unix.py プロジェクト: ixokai/pants
    def __init__(self, socket, server):
        Stream.__init__(self, socket=socket)

        self.server = server
コード例 #13
0
ファイル: unix.py プロジェクト: ixokai/pants
 def __init__(self):
     # This dummy method prevents keyword arguments from finding
     # their way up to the Stream/_Channel constructors.
     Stream.__init__(self, family=socket.AF_UNIX)
コード例 #14
0
ファイル: dns.py プロジェクト: vasudevram/pants
    def __init__(self, resolver, id, **kwargs):
        Stream.__init__(self, **kwargs)
        self.resolver = resolver
        self.id = id

        self.response = ''