From ceb36f81aea71a1df7a23271e66eae912085b959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Aime?= Date: Thu, 25 Mar 2021 15:01:58 +0100 Subject: [PATCH] Adding Wi-Fi network priority #55 --- server/frontend/app/classes/network.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/frontend/app/classes/network.py b/server/frontend/app/classes/network.py index 0007a47..db5aa21 100644 --- a/server/frontend/app/classes/network.py +++ b/server/frontend/app/classes/network.py @@ -92,7 +92,8 @@ class Network(object): net = {} for line in block.splitlines(): if line and line != "}": - key, val = line.strip().split("=") + if "priority=10" not in line.strip(): + key, val = line.strip().split("=") if key != "disabled": net[key] = val.replace("\"", "") networks.append(net) @@ -100,13 +101,15 @@ class Network(object): for net in networks: if net["ssid"] == ssid: net["psk"] = password.replace('"', '\\"') + net["priority"] = "10" found = True if not found: networks.append({ "ssid": ssid, "psk": password.replace('"', '\\"'), - "key_mgmt": "WPA-PSK" + "key_mgmt": "WPA-PSK", + "priority": "10" }) with open("/etc/wpa_supplicant/wpa_supplicant.conf", "w+") as f: