def _onRemoteShellInput( self, command ): if six.PY2: command = Any.Utf8( command ) if not command: # f.i. just RETURN pressed for terminal in self.visibleRemoteTerminals: terminal.writeCommand( '' ) terminal.setColor( 'grey' ) elif command.startswith( 'cd' ): # 'cd' is not a command but a shell built-in, # f.i. there is no /bin/cd executable try: path = shlex.split( command )[1] except IndexError: # no directory specified, falling back to home directory path = os.path.expanduser( '~' ) # show original path typed by user for terminal in self.visibleRemoteTerminals: terminal.writeCommand( 'cd %s' % path ) terminal.setColor( 'green' ) # but unsure if exists terminal.setPath( path ) elif command == 'exit' or command == 'quit': self.quit() else: # execute real executable self._focusRemoteTerminals() self._execProgramParallel( command )
def _onLocalShellInput( self, command ): if six.PY2: command = Any.Utf8( command ) if not command: # f.i. just RETURN pressed terminal = self.terminals[ 'localhost' ] terminal.writeCommand( '' ) terminal.setColor( 'grey' ) elif command.startswith( 'cd' ): # 'cd' is not a command but a shell built-in, # f.i. there is no /bin/cd executable path = shlex.split( command )[1] # show original path typed by user terminal = self.terminals[ 'localhost' ] terminal.writeCommand( 'cd %s' % path ) # proceed with full path path = os.path.expanduser( path ) if os.path.exists( path ): terminal.setColor( 'green' ) terminal.setPath( path ) FastScript.changeDirectory( path ) else: terminal.setColor( 'red' ) terminal.writeText( '%s: No such directory' % path ) elif command == 'exit' or command == 'quit': self.quit() else: # execute real executable self._focusLocalTerminal() self._execProgram( self.terminals[ 'localhost' ], command )