From 934602ee0906783b09f870bfc641f70c054c4cec Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Sun, 16 Jun 2019 01:30:17 -0500 Subject: [PATCH] handle keyboardinterrupt, eof and blank file path in interactive ui --- onionr/static-data/default-plugins/cliui/main.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/onionr/static-data/default-plugins/cliui/main.py b/onionr/static-data/default-plugins/cliui/main.py index e1398a13..c4186b81 100755 --- a/onionr/static-data/default-plugins/cliui/main.py +++ b/onionr/static-data/default-plugins/cliui/main.py @@ -39,8 +39,6 @@ class OnionrCLIUI: def subCommand(self, command, args=None): try: - #subprocess.run(["./onionr.py", command]) - #subprocess.Popen(['./onionr.py', command], stdin=subprocess.STD, stdout=subprocess.STDOUT, stderr=subprocess.STDOUT) if args != None: subprocess.call(['./onionr.py', command, args]) else: @@ -89,8 +87,13 @@ class OnionrCLIUI: else: print('Plugin not enabled') elif choice in ("3", "file sharing", "file"): - filename = input("Enter full path to file: ").strip() - self.subCommand("addfile", filename) + try: + filename = input("Enter full path to file: ").strip() + except (EOFError, KeyboardInterrupt) as e: + pass + else: + if len(filename.strip()) > 0: + self.subCommand("addfile", filename) elif choice in ("4", "quit"): showMenu = False self.shutdown = True