From 0ace93bbf2049a8da1ad8a002da5ecb8b2bae3b9 Mon Sep 17 00:00:00 2001 From: Yaroslav Brustinov Date: Tue, 23 Aug 2016 20:53:58 +0300 Subject: fixes to create config script: in case of error input, ask again. --- scripts/dpdk_nic_bind.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'scripts/dpdk_nic_bind.py') diff --git a/scripts/dpdk_nic_bind.py b/scripts/dpdk_nic_bind.py index bd4ec739..d9df92e0 100755 --- a/scripts/dpdk_nic_bind.py +++ b/scripts/dpdk_nic_bind.py @@ -58,6 +58,11 @@ table_flag = False force_flag = False args = [] +try: + raw_input +except: # Python3 + raw_input = input + def usage(): '''Print usage information for the program''' argv0 = basename(sys.argv[0]) @@ -352,19 +357,22 @@ def read_pid_cmdline(pid): return f.read().replace(b'\0', b' ').decode(errors = 'replace') def confirm(msg, default = False): + if not os.isatty(1): + return default + termios.tcflush(sys.stdin, termios.TCIOFLUSH) try: - if not os.isatty(1): - return default - termios.tcflush(sys.stdin, termios.TCIOFLUSH) return strtobool(raw_input(msg)) - except: + except KeyboardInterrupt: + print('') + sys.exit(1) + except Exception: return default def read_line(msg = '', default = ''): + if not os.isatty(1): + return default + termios.tcflush(sys.stdin, termios.TCIOFLUSH) try: - if not os.isatty(1): - return default - termios.tcflush(sys.stdin, termios.TCIOFLUSH) return raw_input(msg).strip() except KeyboardInterrupt: print('') -- cgit 1.2.3-korg