Hanterar felaktiga menyval

This commit is contained in:
2018-07-14 12:13:58 +02:00
parent 658a221900
commit d55c292201

12
alla.py
View File

@@ -134,9 +134,17 @@ if __name__ == '__main__':
data = read_file(cfg) # Open the data file
if not args.site: # Show a menu if no input
while True:
menu(data)
site = input("Key #: ")
if site:
site = raw_input("Key #: ")
try:
site = int(site)
except:
print("Enter a number, not text.")
if site > len(data):
raw_input("Incorrect menu choice, press Enter to try again")
else:
print_OTP(data[site-1]["secret"]) # -1 since index start with 0 and the menu with 1
exit(0)