From 6e5dbc2a6b2cc06548a4b087958437901460c2d4 Mon Sep 17 00:00:00 2001 From: IrvingGao <1729854488@qq.com> Date: Mon, 20 May 2024 23:13:24 +0800 Subject: [PATCH] update --- wifi_manager.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/wifi_manager.py b/wifi_manager.py index ed92f9e..04a8133 100644 --- a/wifi_manager.py +++ b/wifi_manager.py @@ -83,7 +83,12 @@ def scan_wifi(): wifi_list.append({'ssid': ssid, 'signal': strength}) if len(wifi_list) == 15: break - + + # save wifi_list to file + with open('wifi_list.txt', 'w') as f: + for wifi in wifi_list: + f.write(f"{wifi['ssid']},{wifi['signal']}\n") + return wifi_list except subprocess.CalledProcessError as e: print(f"Error scanning for Wi-Fi networks: {e}") @@ -158,10 +163,6 @@ if __name__ == '__main__': print("----------------------------") wifi_list = scan_wifi() print("----------------------------") - # save wifi_list to file - with open('wifi_list.txt', 'w') as f: - for wifi in wifi_list: - f.write(f"{wifi['ssid']},{wifi['signal']}\n") restart_hotspot() # 启动 Flask 服务器