diff options
author | coderick14 | 2017-06-14 15:54:40 +0530 |
---|---|---|
committer | coderick14 | 2017-06-14 15:54:40 +0530 |
commit | 57190d1a28b07668459c7da244f2e5d40bde1654 (patch) | |
tree | 2c9bbc6b6dc2e687e9136c4a6c0f7f1adb42dd96 /sbhs_server/create_ip_map.py | |
parent | bab1bd450b649bcb79d10cde62028e7e2eb6f39e (diff) | |
download | SBHS-2018-Rpi-57190d1a28b07668459c7da244f2e5d40bde1654.tar.gz SBHS-2018-Rpi-57190d1a28b07668459c7da244f2e5d40bde1654.tar.bz2 SBHS-2018-Rpi-57190d1a28b07668459c7da244f2e5d40bde1654.zip |
Add script to scan RPi's
Diffstat (limited to 'sbhs_server/create_ip_map.py')
-rw-r--r-- | sbhs_server/create_ip_map.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sbhs_server/create_ip_map.py b/sbhs_server/create_ip_map.py new file mode 100644 index 0000000..2964be0 --- /dev/null +++ b/sbhs_server/create_ip_map.py @@ -0,0 +1,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)
\ No newline at end of file |