def startshell(self, connect=True): """ start the console bot. """ self.start(False) print(getfullversion("CONSOLE")) while not self.stopped: try: mainhandler.handle_one() input = console.raw_input("\n> ") if self.stopped: return event = ConsoleEvent() event.parse(self, input, console) event.nooutput = True event.nodispatch = False e = self.put(event) res = e.wait() if res: sys.stdout.write("\n") txt = self.makeresponse(res, dot="<br>") self.out(e.userhost, txt) sys.stdout.flush() except TLStop: break except IOError: break except NoInput: continue except (KeyboardInterrupt, EOFError): break except Exception as ex: handle_exception() ; break console.save_history()
def mainloop(): """ function to be used as mainloop. """ while 1: try: time.sleep(1) mainhandler.handle_one() except TLStop: break except KeyboardInterrupt: break except Exception as ex: handle_exception() break globalshutdown()