Ejemplo n.º 1
0
def start():
    shell = KeykitShell()
    completer = Completer(shell=shell)

    # Load history
    try:
        readline.read_history_file(PYCONSOLE_HIST_FILE)
    except IOError:
        warn("Can't read history file")

    # Load help system in background thread
    doc_thread = Thread(target=load_keykit_library)
    doc_thread.start()

    # Start Input loop
    try:
        shell.cmdloop()
    except KeyboardInterrupt:
        warn("Ctrl+C pressed. Quitting keykit shell.")
        shell.close()
    except TypeError:
        warn("Type error. Quitting keykit shell.")
        shell.close()
    finally:
        shell.close()

    # Write history
    try:
        readline.set_history_length(100000)
        readline.write_history_file(".pyconsole.history")
    except IOError:
        warn("Can't write history file")
Ejemplo n.º 2
0
    def evaluate(self):
        while (not self.__input_queue.empty()):
            # clear line
            sys.stdout.write('\r\033[2K')
            sys.stdout.flush()

            self.__shell.push(self.__input_queue.get())

            #write new prompt
            sys.stdout.write(print_green + self.Prompt.value + print_reset)
            sys.stdout.flush()

            readline.write_history_file(self.HistoryFile.value)
  def evaluate(self):
    while (not self.__input_queue.empty()):
      # clear line
      sys.stdout.write('\r\033[2K')
      sys.stdout.flush()

      self.__shell.push(self.__input_queue.get())

      #write new prompt
      sys.stdout.write(print_green + self.Prompt.value + print_reset)
      sys.stdout.flush()

      readline.write_history_file(self.HistoryFile.value)
Ejemplo n.º 4
0
		try:
			while True:
				if catcherrors:
					try:
						self.run_once()
					except ICmdError, e:
						sys.stderr.write('%s\n' % (e.args[1]))
						logging.info("ICmd.run intercepted an error: %s" % (e))
					except EOFError, e:
						break
				else:
					self.run_once()
		except (SystemExit, KeyboardInterrupt):
			if 'readline' in sys.modules or 'pyreadline' in sys.modules:
				logging.info("Writing readline command history")
				readline.write_history_file(self.histfile)

		return(True)

if __name__ == "__main__":
	class ICmdTest(ICmdBase):
		def load(self, fname):
			"""
			Load a file
			Load the file indicated by FNAME.
			"""
			self.fname = fname
			print "Loading %s" % (self.fname)

		def save(self):
			"""
    try:
        sys.stdout.write(", madIS: "+functions.VERSION+'\n')
    except:
        print
    print intromessage

number_of_kb_exceptions=0
while True:
    statement = raw_input_no_history("mterm> ")
    if statement==None:
        number_of_kb_exceptions+=1
        print
        if number_of_kb_exceptions<2:
            continue
        else:
            readline.write_history_file(histfile)
            break

    #Skip comments
    if statement.startswith('--'):
        continue

    number_of_kb_exceptions=0
    statement=statement.decode(output_encoding)
    #scan for commands
    iscommand=re.match("\s*\.(?P<command>\w+)\s*(?P<argument>([\w\.]*))(?P<rest>.*)$", statement)
    validcommand=False

    if iscommand:
        validcommand=True
        command=iscommand.group('command')
Ejemplo n.º 6
0
    try:
        sys.stdout.write(", madIS: " + functions.VERSION + '\n')
    except:
        print
    print intromessage

number_of_kb_exceptions = 0
while True:
    statement = raw_input_no_history("mterm> ")
    if statement == None:
        number_of_kb_exceptions += 1
        print
        if number_of_kb_exceptions < 2:
            continue
        else:
            readline.write_history_file(histfile)
            break

    # Skip comments
    if statement.startswith('--'):
        continue

    number_of_kb_exceptions = 0
    statement = statement.decode(output_encoding)
    # scan for commands
    iscommand = re.match("\s*\.(?P<command>\w+)\s*(?P<argument>([\w\.]*))(?P<rest>.*)$", statement)
    validcommand = False
    queryplan = False

    if iscommand:
        validcommand = True