[scan] wifi
This commit is contained in:
parent
c2e884a599
commit
0e1e3f442d
|
@ -160,6 +160,7 @@ def init_networkmanager_file():
|
|||
def check_wifi_connection():
|
||||
cmd = "nmcli dev status"
|
||||
result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
|
||||
time.sleep(1) # 等待1秒,确保nmcli命令执行完成
|
||||
output = result.stdout.strip()
|
||||
lines = output.split("\n")[1:] # Skip the header line
|
||||
for line in lines:
|
||||
|
@ -358,13 +359,15 @@ if __name__ == '__main__':
|
|||
|
||||
init_networkmanager_file() # 初始化 NetworkManager 配置文件
|
||||
|
||||
# 扫描Wi-Fi
|
||||
wifi_list = scan_wifi()
|
||||
|
||||
connected, wifi_ssid = check_wifi_connection()
|
||||
if connected:
|
||||
logging.info(f"{datetime.datetime.now()}: 系统已自动连接到 Wi-Fi 网络,退出程序")
|
||||
close_app()
|
||||
|
||||
# 扫描Wi-Fi
|
||||
wifi_list = scan_wifi()
|
||||
|
||||
# 连接保存的Wi-Fi
|
||||
connected, wifi_ssid = connect_saved_wifi(wifi_list)
|
||||
if connected:
|
||||
|
|
Loading…
Reference in New Issue