scannetworks functions
This commit is contained in:
parent
b130fa2e2d
commit
2a902ed416
59
server.py
59
server.py
@ -116,6 +116,29 @@ class DummyProcess():
|
|||||||
# pass
|
# pass
|
||||||
|
|
||||||
|
|
||||||
|
output = subprocess.check_output(['sudo', 'iwlist', 'wlan0', 'scan'])
|
||||||
|
output_str = output.decode('utf-8')
|
||||||
|
lines = output_str.split('Cell')
|
||||||
|
|
||||||
|
networks = {}
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
if 'ESSID:""\n' not in line and 'Scan completed' not in line:
|
||||||
|
ssid = line.split('ESSID:')[1].split('\n')[0]
|
||||||
|
ssid = ssid.replace('"', '', 1)
|
||||||
|
ssid = ssid[::-1].replace('"', '', 1)[::-1]
|
||||||
|
if 'AES' in ssid:
|
||||||
|
ssid = ssid.replace("AES", "CCMP")
|
||||||
|
try:
|
||||||
|
group_cipher = line.split('Group Cipher : ')[1].split('\n')[0]
|
||||||
|
pair_cipher = line.split('Pairwise Ciphers (1) : ')[1].split('\n')[0]
|
||||||
|
except:
|
||||||
|
group_cipher = ''
|
||||||
|
pair_cipher = ''
|
||||||
|
# quality = line.split('Quality=')[1].split('Signal level')[0].replace(" ", "")
|
||||||
|
networks[ssid] = {'group_cipher': group_cipher, 'pair_cipher': pair_cipher}
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
@app.route("/", methods=['GET', 'POST'])
|
@app.route("/", methods=['GET', 'POST'])
|
||||||
def index():
|
def index():
|
||||||
@ -375,7 +398,10 @@ def index():
|
|||||||
wifi_PSK = wifiline[6][5:].replace('"','')
|
wifi_PSK = wifiline[6][5:].replace('"','')
|
||||||
except:
|
except:
|
||||||
wifi_PSK = ''
|
wifi_PSK = ''
|
||||||
|
try:
|
||||||
|
networks_list = networks
|
||||||
|
except:
|
||||||
|
networks_list = ''
|
||||||
|
|
||||||
templateData = {
|
templateData = {
|
||||||
'system_info':system_info,
|
'system_info':system_info,
|
||||||
@ -408,7 +434,8 @@ def index():
|
|||||||
'wifi_PSK':wifi_PSK,
|
'wifi_PSK':wifi_PSK,
|
||||||
'scheduler_settings':scheduler_settings,
|
'scheduler_settings':scheduler_settings,
|
||||||
'economic_settings':economic_settings,
|
'economic_settings':economic_settings,
|
||||||
'jokes_settings':jokes_settings
|
'jokes_settings':jokes_settings,
|
||||||
|
'networks_list': networks_list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1705,6 +1732,34 @@ def savePromptStartStop():
|
|||||||
return index()
|
return index()
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/scanNetworks", methods=["PUT", "POST"])
|
||||||
|
def scanNetworks2():
|
||||||
|
output = subprocess.check_output(['sudo', 'iwlist', 'wlan0', 'scan'])
|
||||||
|
output_str = output.decode('utf-8')
|
||||||
|
lines = output_str.split('Cell')
|
||||||
|
|
||||||
|
global networks
|
||||||
|
networks = {}
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
if 'ESSID:""\n' not in line and 'Scan completed' not in line:
|
||||||
|
ssid = line.split('ESSID:')[1].split('\n')[0]
|
||||||
|
ssid = ssid.replace('"', '', 1)
|
||||||
|
ssid = ssid[::-1].replace('"', '', 1)[::-1]
|
||||||
|
if 'AES' in ssid:
|
||||||
|
ssid = ssid.replace("AES", "CCMP")
|
||||||
|
try:
|
||||||
|
group_cipher = line.split('Group Cipher : ')[1].split('\n')[0]
|
||||||
|
pair_cipher = line.split('Pairwise Ciphers (1) : ')[1].split('\n')[0]
|
||||||
|
except:
|
||||||
|
group_cipher = ''
|
||||||
|
pair_cipher = ''
|
||||||
|
# quality = line.split('Quality=')[1].split('Signal level')[0].replace(" ", "")
|
||||||
|
networks[ssid] = {'group_cipher': group_cipher, 'pair_cipher': pair_cipher}
|
||||||
|
|
||||||
|
return (networks)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
app.run(host='0.0.0.0', port=1024, debug=False) # the debuggger causes flickering
|
app.run(host='0.0.0.0', port=1024, debug=False) # the debuggger causes flickering
|
||||||
|
Loading…
Reference in New Issue
Block a user