Skip to content

Commit

Permalink
for ventilator
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed May 23, 2023
1 parent b4e171d commit fa0c5c7
Show file tree
Hide file tree
Showing 4 changed files with 220,856 additions and 275,005 deletions.
28 changes: 28 additions & 0 deletions change_device_ip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import json
import os

input_file = os.getenv("IN", "mock_data/data.json")
output_file = os.getenv("OUT", input_file)

with open(input_file, "r") as f:
data = f.read()
data = json.loads(data)


def update_device_id():
"""Adds 100 to the last octet of the IP address"""
list_of_lists_of_lists = data[:]
for list_of_lists in list_of_lists_of_lists:
for list_of_dicts in list_of_lists:
for dict_ in list_of_dicts:
ip = dict_["device_id"]
ip = ip.split(".")
ip[-1] = str(int(ip[-1]) + 100)
ip = ".".join(ip)
dict_["device_id"] = ip

with open(output_file, "w") as f:
f.write(json.dumps(list_of_lists_of_lists, indent=4))


update_device_id()
Loading

0 comments on commit fa0c5c7

Please sign in to comment.