From 66456506102dc413bb40079a61977642c0f78895 Mon Sep 17 00:00:00 2001 From: Rich Date: Sun, 4 Jul 2021 10:50:38 +0100 Subject: [PATCH] Working before disconnect --- app/routes.py | 11 ++++++----- config.py | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/routes.py b/app/routes.py index c17555f..b658be7 100644 --- a/app/routes.py +++ b/app/routes.py @@ -10,8 +10,8 @@ from app.models import Network, Networks, User from config import debug CMD_SCAN = "sudo nmcli -t -f SSID,SIGNAL,IN-USE,SECURITY -e yes -m tab device wifi list ifname wlxf81a6719febb --rescan yes" -CMD_JOIN = 'sudo nmcli device wifi connect "*SSID*" ifname wlxf81a6719febb' -CMD_JOINPW = 'sudo nmcli device wifi connect "*SSID*" ifname wlxf81a6719febb password "*PASSWORD*"' +CMD_JOIN = "sudo nmcli device wifi connect *SSID* ifname wlxf81a6719febb" +CMD_JOINPW = "sudo nmcli device wifi connect *SSID* ifname wlxf81a6719febb password *PASSWORD*" # Error: Connection activation failed: (7) Secrets were required, but not provided. # Device 'wlxf81a6719febb' successfully activated with '11111-1111-11111-111111-11111111' @@ -23,6 +23,7 @@ def scan_networks(): t = line.split(":") if t[0] != "": scan.append(line) + return scan @@ -78,11 +79,11 @@ def wpa(ssid): cmd = CMD_JOINPW.replace("*SSID*", ssid) cmd = cmd.replace("*PASSWORD*", form.password.data) - output = subprocess.run(cmd.split(" "), stdout=subprocess.PIPE).stdout.decode("utf-8") - if output.find("Error") == "-1": + output = subprocess.run(cmd.split(" "), stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdout.decode("utf-8") + if output.find("Error") == -1: return "Successfully connected to {}".format(ssid) - return "Failed to connect to {} {} {}".format(ssid, pformat(cmd.split(" ")), cmd) + return "Failed to connect to {}".format(ssid) return render_template("wpa.html", title="WPA Password", form=form) diff --git a/config.py b/config.py index 54b5512..8d63d90 100644 --- a/config.py +++ b/config.py @@ -2,7 +2,7 @@ import os basedir = os.path.abspath(os.path.dirname(__file__)) -debug = False +debug = True class Config(object):