handle keyboardinterrupt, eof and blank file path in interactive ui

This commit is contained in:
Kevin Froman 2019-06-16 01:30:17 -05:00
parent 8bbf9b10ab
commit 934602ee09

View File

@ -39,8 +39,6 @@ class OnionrCLIUI:
def subCommand(self, command, args=None): def subCommand(self, command, args=None):
try: try:
#subprocess.run(["./onionr.py", command])
#subprocess.Popen(['./onionr.py', command], stdin=subprocess.STD, stdout=subprocess.STDOUT, stderr=subprocess.STDOUT)
if args != None: if args != None:
subprocess.call(['./onionr.py', command, args]) subprocess.call(['./onionr.py', command, args])
else: else:
@ -89,8 +87,13 @@ class OnionrCLIUI:
else: else:
print('Plugin not enabled') print('Plugin not enabled')
elif choice in ("3", "file sharing", "file"): elif choice in ("3", "file sharing", "file"):
filename = input("Enter full path to file: ").strip() try:
self.subCommand("addfile", filename) 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"): elif choice in ("4", "quit"):
showMenu = False showMenu = False
self.shutdown = True self.shutdown = True