diff --git a/main.py b/main.py index c989477..a423769 100644 --- a/main.py +++ b/main.py @@ -50,12 +50,16 @@ GPIO.setmode(GPIO.BCM) greenLed = 14 redLed = 4 -bad = False +# badCredentials = False GPIO.setup(greenLed, GPIO.OUT) GPIO.output(greenLed, GPIO.LOW) GPIO.setup(redLed, GPIO.OUT) GPIO.output(redLed, GPIO.LOW) +def badCred(): + print("Bad credential!") + # badCredentials = True + # time.sleep(2) class CliInteraction(UserInteraction): def prompt_up(self): print("\nTouch your authenticator device now...\n") @@ -67,14 +71,10 @@ class CliInteraction(UserInteraction): print("User Verification required.") return True -def badCred(): - print("Bad credential!") - bad = True - # time.sleep(2) while True: # GPIO.output(14, GPIO.LOW) print("Waiting for device...") - bad = False + badCredentials = False while True: try: # GPIO.output(14, GPIO.LOW) @@ -146,12 +146,14 @@ while True: else: print("No data found for AAGUID:", aaguid) badCred() + raise Exception return None # Close communication with the database cur.close() except (Exception, psycopg2.DatabaseError) as error: print(error) + raise Exception finally: if conn is not None: conn.close() @@ -173,7 +175,7 @@ while True: pk_neg3 = aaguid_data["pk_neg3"] pickled = aaguid_data["pickled"] - if bad: + if badCredentials: raise Exception credentials = pickle.loads(pickled)