예제 #1
0
 def __init__(self, sock, in_fd, out_fd, err_fd):
     self._sock = sock
     self._input_reader = NailgunStreamReader(in_fd,
                                              self._sock) if in_fd else None
     self._stdout = out_fd
     self._stderr = err_fd
     self.remote_pid = None
예제 #2
0
    def _nailgunned_stdio(self, sock):
        """Redirects stdio to the connected socket speaking the nailgun protocol."""
        # Determine output tty capabilities from the environment.
        _, stdout_isatty, stderr_isatty = NailgunProtocol.isatty_from_env(
            self._env)

        # Construct a StreamReader for stdin.
        stdin_reader = NailgunStreamReader(sys.stdin, sock)

        # Construct StreamWriters for stdout, stderr.
        streams = (NailgunStreamWriter(sock,
                                       ChunkType.STDOUT,
                                       isatty=stdout_isatty),
                   NailgunStreamWriter(sock,
                                       ChunkType.STDERR,
                                       isatty=stderr_isatty), stdin_reader)

        # Launch the stdin StreamReader and redirect stdio.
        with stdin_reader.running(), stdio_as(*streams):
            yield
예제 #3
0
 def setUp(self):
     self.in_fd = FakeFile()
     self.mock_socket = mock.Mock()
     self.reader = NailgunStreamReader(in_fd=self.in_fd,
                                       sock=self.mock_socket)