Archived
1
0
Fork 0

Fix strings

This commit is contained in:
Ethanell 2019-03-22 08:45:27 +01:00
parent e91c16947a
commit 60d1529c89

View file

@ -13,11 +13,9 @@ def ap(switch):
def writeconfig(ssid, password): def writeconfig(ssid, password):
rtline = "\n" rtline = "\n"
with io.open("/etc/wpa_supplicant/wpa_supplicant.conf", "w", encoding="utf8") as note: with io.open("/etc/wpa_supplicant/wpa_supplicant.conf", "w", encoding="utf8") as note:
conf = "ctrl_interface=/var/run/wpa_supplicant\nupdate_config=1\ncountry=FR\nnetwork={\nssid=\"" conf = str()
conf += ssid for i in ["ctrl_interface=/var/run/wpa_supplicant\nupdate_config=1\ncountry=FR\nnetwork={\nssid=\"", ssid, "\"\nscan_ssid=1\npsk=\"", password, "\"\n}"]:
conf += "\"\nscan_ssid=1\npsk=\"" conf += i
conf += password
conf += "\"\n}"
note.write(conf) note.write(conf)
ap(False) ap(False)
subprocess.check_call(["sudo", "wpa_cli", "-i", "wlan0", "reconfigure"]) subprocess.check_call(["sudo", "wpa_cli", "-i", "wlan0", "reconfigure"])
@ -38,7 +36,9 @@ def web_setup():
else: else:
writeconfig(request.args.get("ssid"), request.args.get("password")) writeconfig(request.args.get("ssid"), request.args.get("password"))
if testinternet(): if testinternet():
r = get(f"http://flifloo.ddns.net:5000/locksetup?mac={io.open("/sys/class/net/wlan0/address").read()}&id={io.open("/sys/class/net/wlan0/address").read()}") mac = io.open("/sys/class/net/wlan0/address").read()
id = request.args.get("id")
r = get(f"http://flifloo.ddns.net:5000/locksetup?mac={mac}&id={id}")
else: else:
ap(True) ap(True)
return "Cant connect" return "Cant connect"