forked from ohcnetwork/mock-cns-req
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b4e171d
commit fa0c5c7
Showing
4 changed files
with
220,856 additions
and
275,005 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Oops, something went wrong.