first commit
This commit is contained in:
parent
c515650f33
commit
8b1c300f96
|
@ -34,11 +34,6 @@ def scan_wifi():
|
|||
output = subprocess.check_output(['nmcli', 'dev', 'wifi'])
|
||||
wifi_list = []
|
||||
lines = output.decode().splitlines()
|
||||
print(lines)
|
||||
print(len(lines))
|
||||
# for new in lines.split("', '"):
|
||||
# print(f"new: {new}")
|
||||
print("###### ")
|
||||
for idx, line in enumerate(lines[1:]):
|
||||
print(f"{idx}: {line}")
|
||||
|
||||
|
@ -51,7 +46,6 @@ def scan_wifi():
|
|||
ssid = " ".join(columns[1:3])
|
||||
if "Infra" in ssid:
|
||||
ssid = ssid.replace(" Infra", "")
|
||||
print("ssid: ", ssid.strip())
|
||||
|
||||
# 提取第六列的强度值
|
||||
last_info = columns[4:8]
|
||||
|
@ -60,10 +54,9 @@ def scan_wifi():
|
|||
# 提取"Mbit/s"后两位数字
|
||||
strength = int(columns[columns.index("Mbit/s")+6:columns.index("Mbit/s")+8])
|
||||
|
||||
|
||||
print("MAC地址:", mac_address)
|
||||
print("SSID:", ssid)
|
||||
print("强度:", strength)
|
||||
# print("MAC地址:", mac_address)
|
||||
# print("SSID:", ssid)
|
||||
# print("强度:", strength)
|
||||
|
||||
wifi_list.append({'ssid': ssid, 'signal': strength})
|
||||
if len(wifi_list) == 15:
|
||||
|
@ -140,8 +133,9 @@ def submit():
|
|||
stop_hotspot() # 关闭热点
|
||||
return redirect(url_for('index'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
debug_mode = True # 设置为 True 以跳过 Wi-Fi 连接状态检测
|
||||
debug_mode = False # 设置为 True 以跳过 Wi-Fi 连接状态检测
|
||||
|
||||
if not debug_mode:
|
||||
if check_wifi_connection():
|
||||
|
|
Loading…
Reference in New Issue