-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.py
76 lines (59 loc) · 1.86 KB
/
Main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#This is the program used to map the lcation of the wifi router.
import requests
import os
import time
import json as js
devicelist = {}
with open("backup.json",'r') as file:
devicelist = js.load(file)
def enable():
os.system('netsh wlan connect name="LWSD-WLAN" interface="wi-fi"')
time.sleep(2)
def disable():
os.system("netsh wlan disconnect")
time.sleep(2)
header = {
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36 Edg/94.0.992.38"
}
url = "http://my.meraki.com/index.json"
ses = requests.Session()
b = 0
while True:
b+=1
try:
#enable()
resp = ses.get(url=url).json()
lat = resp["config"]["lat"]
lon = resp["config"]["lng"]
nodename = resp["config"]["node_name"]
max_bitrate = resp["client"]["max_device_bitrate"]
channels = []
for i in resp["radio_stats"]:
channels.append(i["channel"])
if devicelist.get(resp["config"]["mac"])== None:
devicelist[resp["config"]["mac"]]={
"latitude":lat,
"longitude":lon,
"nodename":nodename,
"channels":channels,
"max_bitrate":max_bitrate
}
print(nodename)
if b %10==0:
with open("backup.json",'w') as file:
js.dump(devicelist,file,indent=2)
print(devicelist)
file.close()
except requests.exceptions.ConnectionError:
enable()
time.sleep(2)
continue
except KeyboardInterrupt:
with open("backup.json",'w') as file:
js.dump(devicelist,file,indent=2)
print(devicelist)
file.close()
disable()
#time.sleep(1)
enable()
time.sleep(1)