Hanterar felaktiga menyval
This commit is contained in:
12
alla.py
12
alla.py
@@ -134,9 +134,17 @@ if __name__ == '__main__':
|
|||||||
data = read_file(cfg) # Open the data file
|
data = read_file(cfg) # Open the data file
|
||||||
|
|
||||||
if not args.site: # Show a menu if no input
|
if not args.site: # Show a menu if no input
|
||||||
|
while True:
|
||||||
menu(data)
|
menu(data)
|
||||||
site = input("Key #: ")
|
site = raw_input("Key #: ")
|
||||||
if site:
|
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
|
print_OTP(data[site-1]["secret"]) # -1 since index start with 0 and the menu with 1
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user