add adapter reset to exception handlers in test
This commit is contained in:
1 parent
9c63de343a
commit
d1fa64c7fd
1 file changed
+5
-1
+5
-1
@@ -221,9 +221,11 @@ def read_data_sync(mac: str) -> Optional[SensorReading]:
|
||||
# Other helper functions
|
||||
# --------------------------------------------------------------------------- #
|
||||
def reset_adapter():
|
||||
log.info("Restting BT Adapter...")
|
||||
subprocess.run(["sudo", "rfkill", "block", "bluetooth"], check=True)
|
||||
subprocess.run(["sudo", "rfkill", "unblock", "bluetooth"], check=True)
|
||||
time.sleep(5)
|
||||
log.info("Reset complete. ")
|
||||
|
||||
def sensor_data_query(mac_list: List[str]) -> List[dict]:
|
||||
reset_adapter()
|
||||
@@ -235,6 +237,7 @@ def sensor_data_query(mac_list: List[str]) -> List[dict]:
|
||||
print(f"Error reading BLE data - {e}")
|
||||
this_result = None
|
||||
if "org.freedesktop.DBus.Error.AccessDenied" in e:
|
||||
reset_adapter()
|
||||
return result
|
||||
if this_result:
|
||||
result.append(
|
||||
@@ -315,4 +318,5 @@ if __name__ == "__main__":
|
||||
try:
|
||||
test(test_count)
|
||||
except Exception as e:
|
||||
print(f"Test failed brah - {e}")
|
||||
print(f"Test failed brah - {e}")
|
||||
reset_adapter()
|
||||
Reference in new issue
Block a user