Beispiel #1
0
 def __init__(self, tty):
     task.Task.__init__(self)
     self.key_event = task.NullQueue()
     self.get_cursor_position_event = task.Queue()
     self._buff = ''
     self._tty = tty
     self.stdout = os.fdopen(self._tty, 'w', 0)
Beispiel #2
0
    def execute(self, term, command):
        proxy_term = terminal.ProxyTerminal(term)
        proxy_term.key_event = None
        q = task.Queue('executor proxy')
        term.key_event = q

        execution = Execution(self, self.state, proxy_term)
        def execute():
            execution.execute(command)
            q.stop()

        task.async(execute)

        for event in q:
            if proxy_term.key_event:
                # inferior is able to process ctrl-c itself
                proxy_term.key_event.post(event)
            else:
                if isinstance(event, terminal.KeyEvent) and event.char == '\x03':
                    break
            if isinstance(event, terminal.KeyEvent) and event.char == '\x1c':
                # always terminate
                break

        proxy_term.enabled = False
Beispiel #3
0
 def __init__(self, terminal):
     self.terminal = terminal
     self.buff = ''
     self.pos = 0
     self.q = task.Queue('termedit')
     self.__finished = False
     self.__termwrite = TerminalWriter(terminal)
Beispiel #4
0
 def execute_remote_command(self, args):
     execution = self.state[Transport].execute(args, size=self.terminal.get_size(),
                                               pty=True,
                                               cwd=self.state[CurrentDirectory],
                                               environ={'TERM': 'xterm'})
     q = task.Queue('execute_remote_command')
     execution.read_event = q
     execution.start()
     self.terminal.key_event = q
     self.terminal.check()
     for event in q:
         if isinstance(event, stream.StreamCloseEvent):
             break
         elif isinstance(event, stream.StreamReadEvent):
             self.terminal.write(event.data)
         elif isinstance(event, terminal.KeyEvent):
             execution.write(event.char)
Beispiel #5
0
 def get_cursor_position(self):
     log('get_cursor_position', level=1)
     self.get_cursor_position_event = task.Queue()
     self.write('\x1b[6n')
     data = self.get_cursor_position_event.get()
     return map(int, data.split(';'))[::-1]
Beispiel #6
0
 def __init__(self, output):
     self.q = task.Queue()
     self.output = output