(self, p, shell_output, shell_cerr)
Communicate with launched shell.
Communicate with launched shell.
Communicate with launched shell .
def _communicate(self, p, shell_output, shell_cerr):
        """Communicate with launched shell."""
        word = []
        while p.poll() is None:
            self._show_output(shell_output)
            self._show_output(shell_cerr)
            try:
                self._queues.wait()
                # expand=False suppresses key macros
                c = self._keyboard.get_fullchar(expand=False)
            except error.Break:
                pass
            if not c:
                continue
            elif c in (b'\r', b'\n'):
                # put sentinel on queue
                shell_output.append(b'')
                shell_cerr.append(b'')
                # send the command
                self._send_input(p.stdin, word)
                word = []
            elif c == b'\b':
                # handle backspace
                if word:
                    word.pop()
                    self._console.write(b'\x1D \x1D')
            elif not c.startswith(b'\0'):
                # exclude e-ascii (arrow keys not implemented)
                word.append(c)
                self._console.write(c)
        # drain final output
        self._drain_final(shell_output)
        self._drain_final(shell_cerr)
def _communicate ( self , p , shell_output , shell_cerr ) : word = [ ] while p . poll ( ) is None : self . _show_output ( shell_output ) self . _show_output ( shell_cerr ) try : self . _queues . wait ( ) # expand=False suppresses key macros c = self . _keyboard . get_fullchar ( expand = False ) except error . Break : pass if not c : continue elif c in ( b'\r' , b'\n' ) : # put sentinel on queue shell_output . append ( b'' ) shell_cerr . append ( b'' ) # send the command self . _send_input ( p . stdin , word ) word = [ ] elif c == b'\b' : # handle backspace if word : word . pop ( ) self . _console . write ( b'\x1D \x1D' ) elif not c . startswith ( b'\0' ) : # exclude e-ascii (arrow keys not implemented) word . append ( c ) self . _console . write ( c ) # drain final output self . _drain_final ( shell_output ) self . _drain_final ( shell_cerr )