dist/tools/pyterm: exit without traceback on keyboard interrupt

This commit is contained in:
Alexandre Abadie 2017-11-27 13:19:48 +01:00
parent 4334b2cf6a
commit b109b9ff99

View File

@ -675,10 +675,6 @@ class PytermClientFactory(ReconnectingClientFactory):
reason)
def __stop_reactor(signum, stackframe):
sys.stderr.write("Ctrl-C is disabled, type '/exit' instead\n")
class fdsocket(socket.socket):
def read(self, bufsize):
return self.recv(bufsize)
@ -758,13 +754,15 @@ if __name__ == "__main__":
args.log_dir_name, args.newline, args.format, args.prompt)
myshell.prompt = ''
try:
if args.server and args.tcp_port:
myfactory = PytermClientFactory(myshell)
reactor.connectTCP(args.server, args.tcp_port, myfactory)
myshell.factory = myfactory
reactor.callInThread(myshell.cmdloop, "Welcome to pyterm!\n"
"Type '/exit' to exit.")
signal.signal(signal.SIGINT, __stop_reactor)
reactor.run()
else:
myshell.cmdloop("Welcome to pyterm!\nType '/exit' to exit.")
except KeyboardInterrupt:
myshell.do_PYTERM_exit(None)