block intiial wifi scan, seems to crash the script

This commit is contained in:
Justin 2023-07-19 19:17:06 +08:00 committed by GitHub
parent 726295a526
commit b50fac4e76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -116,27 +116,27 @@ class DummyProcess():
# pass # pass
output = subprocess.check_output(['sudo', 'iwlist', 'wlan0', 'scan']) # output = subprocess.check_output(['sudo', 'iwlist', 'wlan0', 'scan'])
output_str = output.decode('utf-8') # output_str = output.decode('utf-8')
lines = output_str.split('Cell') # lines = output_str.split('Cell')
networks = {} networks = {}
for line in lines: # for line in lines:
if 'ESSID:""\n' not in line and 'Scan completed' not in line: # if 'ESSID:""\n' not in line and 'Scan completed' not in line:
ssid = line.split('ESSID:')[1].split('\n')[0] # ssid = line.split('ESSID:')[1].split('\n')[0]
ssid = ssid.replace('"', '', 1) # ssid = ssid.replace('"', '', 1)
ssid = ssid[::-1].replace('"', '', 1)[::-1] # ssid = ssid[::-1].replace('"', '', 1)[::-1]
if 'AES' in ssid: # if 'AES' in ssid:
ssid = ssid.replace("AES", "CCMP") # ssid = ssid.replace("AES", "CCMP")
try: # try:
group_cipher = line.split('Group Cipher : ')[1].split('\n')[0] # group_cipher = line.split('Group Cipher : ')[1].split('\n')[0]
pair_cipher = line.split('Pairwise Ciphers (1) : ')[1].split('\n')[0] # pair_cipher = line.split('Pairwise Ciphers (1) : ')[1].split('\n')[0]
except: # except:
group_cipher = '' # group_cipher = ''
pair_cipher = '' # pair_cipher = ''
# quality = line.split('Quality=')[1].split('Signal level')[0].replace(" ", "") # # quality = line.split('Quality=')[1].split('Signal level')[0].replace(" ", "")
networks[ssid] = {'group_cipher': group_cipher, 'pair_cipher': pair_cipher} # networks[ssid] = {'group_cipher': group_cipher, 'pair_cipher': pair_cipher}
app = Flask(__name__) app = Flask(__name__)