]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 3 Jun 2023 06:40:56 +0000 (08:40 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 3 Jun 2023 06:40:56 +0000 (08:40 +0200)
- check dictionary keys before using them, prevents KeyError being raised

fetch_blocks.py

index 900f1c0126593ef5ca4400a3cac7caf4e86b17df..154bd9786c2ad17cdb0d906af8fe230ce4af3473 100755 (executable)
@@ -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)