def _process_nailgun_stream()

in nailgun-client/py/ng.py [0:0]


    def _process_nailgun_stream(self):
        """
         Processes a single chunk from the nailgun server.
         """
        self._recv_to_buffer(len(self.header_buf), self.header_buf)
        (chunk_len, chunk_type) = struct.unpack_from(">ic", self.header_buf.raw)

        if chunk_type == CHUNKTYPE_STDOUT:
            self._recv_to_fd(self.stdout, chunk_len)
        elif chunk_type == CHUNKTYPE_STDERR:
            self._recv_to_fd(self.stderr, chunk_len)
        elif chunk_type == CHUNKTYPE_EXIT:
            self._process_exit(chunk_len)
        elif chunk_type == CHUNKTYPE_SENDINPUT:
            # signal stdin thread to get and send more data
            with self.stdin_condition:
                self.stdin_condition.notify()
        else:
            raise NailgunException(
                "Unexpected chunk type: {0}".format(chunk_type),
                NailgunException.UNEXPECTED_CHUNKTYPE,
            )