From: Moritz Warning Date: Sun, 13 Sep 2020 11:35:46 +0000 (+0200) Subject: misc/collect.py: better error messages X-Git-Tag: v3.0.0~9 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=80b625284ad917810668d111864191fa80550276;p=web%2Ffirmware-selector-openwrt-org.git misc/collect.py: better error messages adds a path and newlines to error messages --- diff --git a/misc/collect.py b/misc/collect.py index 9608279..26b9876 100755 --- a/misc/collect.py +++ b/misc/collect.py @@ -31,7 +31,7 @@ def merge_profiles(profiles, download_url): title.get("vendor", ""), title["model"], title.get("variant", "") ).strip() - def add_profile(id, target, profile, code=None): + def add_profile(path, id, target, profile, code=None): images = [] for image in profile["images"]: images.append({"name": image["name"], "type": image["type"]}) @@ -43,7 +43,9 @@ def merge_profiles(profiles, download_url): title = get_title(entry) if len(title) == 0: - sys.stderr.write("Empty title. Skip title for {}".format(id)) + sys.stderr.write( + "Empty title. Skip title for {} in {}\n".format(id, path) + ) continue output["models"][title] = {"id": id, "target": target, "images": images} @@ -56,7 +58,7 @@ def merge_profiles(profiles, download_url): if obj["metadata_version"] != SUPPORTED_METADATA_VERSION: sys.stderr.write( - "{} has unsupported metadata version: {} => skip".format( + "{} has unsupported metadata version: {} => skip\n".format( path, obj["metadata_version"] ) ) @@ -74,9 +76,9 @@ def merge_profiles(profiles, download_url): try: if "profiles" in obj: for id in obj["profiles"]: - add_profile(id, obj.get("target"), obj["profiles"][id], code) + add_profile(path, id, obj.get("target"), obj["profiles"][id], code) else: - add_profile(obj["id"], obj["target"], obj, code) + add_profile(path, obj["id"], obj["target"], obj, code) except json.decoder.JSONDecodeError as e: sys.stderr.write("Skip {}\n {}\n".format(path, e)) except KeyError as e: