From ee9d3a7a589add0a2861048d560e8d1caa7d025f Mon Sep 17 00:00:00 2001 From: Eggman20339 Date: Sun, 5 May 2024 20:14:22 -0400 Subject: [PATCH] error handling for untimley removal of key --- main.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/main.py b/main.py index 2927390..f7f14ec 100644 --- a/main.py +++ b/main.py @@ -72,19 +72,21 @@ while True: # GPIO.output(14, GPIO.LOW) print("Waiting for device...") while True: - # GPIO.output(14, GPIO.LOW) - dev = next(CtapHidDevice.list_devices(), None) + try: + # GPIO.output(14, GPIO.LOW) + dev = next(CtapHidDevice.list_devices(), None) - if dev: - ctap2 = Ctap2(dev) + if dev: + ctap2 = Ctap2(dev) - info = ctap2.get_info() - gotAaguid = info.aaguid - print(str(gotAaguid)) - break - - time.sleep(0.1) + info = ctap2.get_info() + gotAaguid = info.aaguid + print(str(gotAaguid)) + break + time.sleep(0.1) + except Exception as e: + print(e) # Handle user interaction try: