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

pi_ip_map = {}

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

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

for ip in ipaddrs:
	filename = "RPi_data/map/" + 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)