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
|
# Other helper functions
|
||||||
# --------------------------------------------------------------------------- #
|
# --------------------------------------------------------------------------- #
|
||||||
def reset_adapter():
|
def reset_adapter():
|
||||||
|
log.info("Restting BT Adapter...")
|
||||||
subprocess.run(["sudo", "rfkill", "block", "bluetooth"], check=True)
|
subprocess.run(["sudo", "rfkill", "block", "bluetooth"], check=True)
|
||||||
subprocess.run(["sudo", "rfkill", "unblock", "bluetooth"], check=True)
|
subprocess.run(["sudo", "rfkill", "unblock", "bluetooth"], check=True)
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
log.info("Reset complete. ")
|
||||||
|
|
||||||
def sensor_data_query(mac_list: List[str]) -> List[dict]:
|
def sensor_data_query(mac_list: List[str]) -> List[dict]:
|
||||||
reset_adapter()
|
reset_adapter()
|
||||||
@@ -235,6 +237,7 @@ def sensor_data_query(mac_list: List[str]) -> List[dict]:
|
|||||||
print(f"Error reading BLE data - {e}")
|
print(f"Error reading BLE data - {e}")
|
||||||
this_result = None
|
this_result = None
|
||||||
if "org.freedesktop.DBus.Error.AccessDenied" in e:
|
if "org.freedesktop.DBus.Error.AccessDenied" in e:
|
||||||
|
reset_adapter()
|
||||||
return result
|
return result
|
||||||
if this_result:
|
if this_result:
|
||||||
result.append(
|
result.append(
|
||||||
@@ -315,4 +318,5 @@ if __name__ == "__main__":
|
|||||||
try:
|
try:
|
||||||
test(test_count)
|
test(test_count)
|
||||||
except Exception as e:
|
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