Add error handling and print traceback in RFID tests
The update introduces IOError specific exception handling in the RFID tests. It also prints a traceback for both IOError and general exceptions. This is done to better diagnose issues related to connectivity and IO in the tests as and when they occur. The code is also cleaned for better readability by fixing indentation and removing unnecessary comments and spaces.
This commit is contained in:
parent
bd96cf59f7
commit
e2d344cf1e
|
|
@ -2,6 +2,7 @@ import logging
|
||||||
import platform
|
import platform
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
import traceback
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
@ -10,7 +11,6 @@ import ndef
|
||||||
import nfc
|
import nfc
|
||||||
from nfc.clf import RemoteTarget
|
from nfc.clf import RemoteTarget
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
format="{asctime}:{name}:{levelname}:{message}",
|
format="{asctime}:{name}:{levelname}:{message}",
|
||||||
datefmt="%Y-%m-%dT%H-%M-%S%z",
|
datefmt="%Y-%m-%dT%H-%M-%S%z",
|
||||||
|
|
@ -80,8 +80,13 @@ while True:
|
||||||
print("NO TARGET")
|
print("NO TARGET")
|
||||||
else:
|
else:
|
||||||
print("NOT CONNECTED")
|
print("NOT CONNECTED")
|
||||||
|
except IOError as io_err:
|
||||||
|
print(f"IOError: {io_err}")
|
||||||
|
traceback.print_exc()
|
||||||
|
connected = False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"EXCEPTION {e}")
|
print(f"General Exception: {e}")
|
||||||
|
traceback.print_exc()
|
||||||
connected = False
|
connected = False
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user