mpc85xx: fix address config for ws-ap3825i
[openwrt/staging/stintel.git] / scripts / json_overview_image_info.py
1 #!/usr/bin/env python3
2
3 import json
4 from pathlib import Path
5 from os import getenv
6 from sys import argv
7
8 if len(argv) != 2:
9 print("JSON info files script requires ouput file as argument")
10 exit(1)
11
12 output_path = Path(argv[1])
13
14 assert getenv("WORK_DIR"), "$WORK_DIR required"
15
16 work_dir = Path(getenv("WORK_DIR"))
17
18 output = {}
19
20 for json_file in work_dir.glob("*.json"):
21 image_info = json.loads(json_file.read_text())
22 if not output:
23 output.update(image_info)
24 else:
25 # get first (and only) profile in json file
26 device_id = next(iter(image_info["profiles"].keys()))
27 if device_id not in output["profiles"]:
28 output["profiles"].update(image_info["profiles"])
29 else:
30 output["profiles"][device_id]["images"].append(
31 image_info["profiles"][device_id]["images"][0]
32 )
33
34 if output:
35 output_path.write_text(json.dumps(output, sort_keys=True, separators=(",", ":")))
36 else:
37 print("JSON info file script could not find any JSON files for target")