From 3e88c60997a6a19b67a8d790629044398e57e0f3 Mon Sep 17 00:00:00 2001 From: IrvingGao <1729854488@qq.com> Date: Thu, 13 Jun 2024 14:03:32 +0800 Subject: [PATCH] [wifi] short wait time --- wifi_manager.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wifi_manager.py b/wifi_manager.py index 607f4e6..9785409 100644 --- a/wifi_manager.py +++ b/wifi_manager.py @@ -128,7 +128,7 @@ def close_hotspot(): def check_wifi_connection(): cmd = "nmcli dev status" result = subprocess.run(cmd, shell=True, capture_output=True, text=True) - time.sleep(2) + time.sleep(0.5) output = result.stdout.strip() lines = output.split("\n")[1:] # Skip the header line for line in lines: @@ -162,7 +162,7 @@ def check_wifi_connection(): network_error_light_1() subprocess.Popen('sudo systemctl restart NetworkManager', shell=True) # subprocess.run(['sudo', 'systemctl', 'restart', 'NetworkManager'], check=True) - time.sleep(1) + time.sleep(0.5) return check_wifi_connection() return False, None @@ -249,7 +249,7 @@ def connect_wifi(ssid, password): def disconnect_wifi(): try: output = subprocess.check_output(['nmcli', 'dev', 'disconnect', 'iface', 'wlan0']) - time.sleep(1) + time.sleep(0.5) output_str = output.decode('utf-8') # 将输出转换为字符串 if "successfully disconnected" in output_str: print(f"{datetime.datetime.now()}: Wi-Fi disconnected successfully") @@ -308,9 +308,9 @@ def submit(): # 关闭热点 close_hotspot() - time.sleep(1) + time.sleep(0.5) scan_wifi() - time.sleep(1) + time.sleep(0.5) # 连接到用户选择的 Wi-Fi 网络 if connect_wifi(ssid, password):