Hanterar felaktiga menyval
This commit is contained in:
18
alla.py
18
alla.py
@@ -134,11 +134,19 @@ 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
|
||||||
menu(data)
|
while True:
|
||||||
site = input("Key #: ")
|
menu(data)
|
||||||
if site:
|
site = raw_input("Key #: ")
|
||||||
print_OTP(data[site-1]["secret"]) # -1 since index start with 0 and the menu with 1
|
try:
|
||||||
exit(0)
|
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)
|
||||||
|
|
||||||
for p in data: # Try to find a matching site
|
for p in data: # Try to find a matching site
|
||||||
if p["label"].strip().lower() == args.site[0].lower():
|
if p["label"].strip().lower() == args.site[0].lower():
|
||||||
|
|||||||
Reference in New Issue
Block a user