From: Roland Häder Date: Sat, 3 Jun 2023 06:40:56 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f4da560d96a0d0aa1e614c2de7080419979ea439;p=fba.git Continued: - check dictionary keys before using them, prevents KeyError being raised --- diff --git a/fetch_blocks.py b/fetch_blocks.py index 900f1c0..154bd97 100755 --- a/fetch_blocks.py +++ b/fetch_blocks.py @@ -57,6 +57,12 @@ for blocker, software, origin, nodeinfo_url in rows: if json is None: print("WARNING: Could not fetch nodeinfo from blocker:", blocker) continue + elif not "metadata" in json: + print(f"WARNING: json()={len(json)} does not have key 'metadata', blocker='{blocker}'") + continue + elif not "federation" in json["metadata"]: + print(f"WARNING: json()={len(json['metadata'])} does not have key 'federation', blocker='{blocker}'") + continue # DEBUG: print("DEBUG: Updating nodeinfo:", blocker) fba.update_last_nodeinfo(blocker)