summaryrefslogtreecommitdiff
path: root/sbhs_server/create_ip_map.py
blob: 2964be094b6ee1762d3c520b465fae713ef99f71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import json

pi_ip_map = {}
ipaddrs = []

with open("temp/ipaddrs.txt", "r") as filehandler:
	ipaddrs = filehandler.readlines()

ipaddrs = [ip.strip() for ip in ipaddrs]

for ip in ipaddrs:
	filename = "temp/" + ip + ".txt"
	with open(filename, "r") as filehandler:
		for line in filehandler:
			try:
				data = line.split('=')
				pi_ip_map[data[0].strip()] = ip
			except:
				pass
				
json_data = json.dumps(pi_ip_map, indent=2, separators=(',',':'))
with open("pi-ip.json", "w") as filehandler:
	filehandler.write(json_data)