summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-01-13 05:58:18 -0500
committerimarom <imarom@cisco.com>2016-01-13 05:58:18 -0500
commit7ab12e3952b6260059cbd9e19e994a150177ee2a (patch)
treedd7caaf082aa58e034a1999373edda719e46d73d
parent862ec9b81ef22c860d4fb9fa45f0531f1c238bcc (diff)
cntrl+c in middle of line can abort the line instead of exiting
-rwxr-xr-xscripts/automation/trex_control_plane/console/trex_console.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py
index fe909c09..37e33cb7 100755
--- a/scripts/automation/trex_control_plane/console/trex_console.py
+++ b/scripts/automation/trex_control_plane/console/trex_console.py
@@ -557,6 +557,20 @@ class TRexConsole(TRexGeneralCmd):
print "{:<30} {:<30}".format(cmd + " - ", help)
+ # a custorm cmdloop wrapper
+ def start(self):
+ while True:
+ try:
+ self.cmdloop()
+ break
+ except KeyboardInterrupt as e:
+ if not readline.get_line_buffer():
+ raise KeyboardInterrupt
+ else:
+ print ""
+ self.intro = None
+ continue
+
# aliases
do_exit = do_EOF = do_q = do_quit
do_h = do_history
@@ -650,11 +664,11 @@ def main():
if options.tui:
console.do_tui("")
else:
- console.cmdloop()
-
+ console.start()
+
except KeyboardInterrupt as e:
print "\n\n*** Caught Ctrl + C... Exiting...\n\n"
-
+
finally:
stateless_client.disconnect()