aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPadraig Connolly <padraig.connolly@intel.com>2016-11-28 10:21:19 +0000
committerChris Luke <chris_luke@comcast.com>2016-12-01 03:16:48 +0000
commit1f417aac76d44c8ac03879cbc048129eeb1e0cab (patch)
tree95e3160dae85990749cd59e00a0ac1e36e88624e
parenta92501ab703c3009cfdbc646cf8b46b228cfba45 (diff)
vppctl: clean exit cli when ctrl-d or ctrl-c entered
Ctrl-D now exits vpp cli using do_EOF function Ctrl-C now exits cleanly without KeyboardInterrupt Error Change-Id: I09d103df57b9512e572eb66c17c548b9c1801589 Signed-off-by: Padraig Connolly <padraig.connolly@intel.com>
-rwxr-xr-x[-rw-r--r--]vpp-api-test/scripts/vppctl30
1 files changed, 20 insertions, 10 deletions
diff --git a/vpp-api-test/scripts/vppctl b/vpp-api-test/scripts/vppctl
index 872590ccfe7..58a029209b9 100644..100755
--- a/vpp-api-test/scripts/vppctl
+++ b/vpp-api-test/scripts/vppctl
@@ -72,12 +72,16 @@ class Vppctl(Cmd):
def do_exit(self, line):
self.historyWrite()
-
raise SystemExit
def emptyline(self):
pass
+ def do_EOF(self,line):
+ self.historyWrite()
+ sys.stdout.write('\n')
+ raise SystemExit
+
def preloop(self):
if readline and os.path.exists(persishist):
readline.read_history_file(persishist)
@@ -91,16 +95,22 @@ if __name__ == '__main__':
if not len(command_args) > 1:
prompt = Vppctl()
- red_set = '\033[31m'
- norm_set = '\033[0m'
- if sys.stdout.isatty():
+ red_set = '\033[31m'
+ norm_set = '\033[0m'
+ if sys.stdout.isatty():
prompt.prompt = 'vpp# '
- prompt.cmdloop(red_set + " _______ _ " + norm_set + " _ _____ ___ \n" +
- red_set + " __/ __/ _ \ (_)__ " + norm_set + " | | / / _ \/ _ \\\n" +
- red_set + " _/ _// // / / / _ \\" + norm_set + " | |/ / ___/ ___/\n" +
- red_set + " /_/ /____(_)_/\___/ " + norm_set + "|___/_/ /_/ \n")
- else:
- prompt.cmdloop()
+ try:
+ prompt.cmdloop(red_set + " _______ _ " + norm_set + " _ _____ ___ \n" +
+ red_set + " __/ __/ _ \ (_)__ " + norm_set + " | | / / _ \/ _ \\\n" +
+ red_set + " _/ _// // / / / _ \\" + norm_set + " | |/ / ___/ ___/\n" +
+ red_set + " /_/ /____(_)_/\___/ " + norm_set + "|___/_/ /_/ \n")
+ except KeyboardInterrupt:
+ sys.stdout.write('\n')
+ else:
+ try:
+ prompt.cmdloop()
+ except KeyboardInterrupt:
+ sys.stdout.write('\n')
else:
del command_args[0]
stdout_value = " ".join(command_args)