From 0fd33131aa7d9719b5d34c30da5c1c6429a157a4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 18 May 2023 23:09:04 +0200 Subject: [PATCH] Continued: - you better should check an array on a specific key with `key in my_array` --- fetch_blocks.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fetch_blocks.py b/fetch_blocks.py index 2ea4a86..6b0e060 100644 --- a/fetch_blocks.py +++ b/fetch_blocks.py @@ -26,12 +26,13 @@ for blocker, software in fba.c.fetchall(): federation = reqto.get( f"https://{blocker}/nodeinfo/2.1.json", headers=fba.headers, timeout=5 ).json()["metadata"]["federation"] + if "mrf_simple" in federation: for block_level, blocks in ( {**federation["mrf_simple"], **{"quarantined_instances": federation["quarantined_instances"]}} ).items(): - # NOISY-DEBUG: print("DEBUG: block_level, blocks.items():", block_level, len(blocks.items())) + # NOISY-DEBUG: print("DEBUG: block_level, blocks():", block_level, len(blocks)) block_level = fba.tidyup(block_level) # NOISY-DEBUG: print("DEBUG: BEFORE block_level:", block_level) @@ -348,13 +349,10 @@ for blocker, software in fba.c.fetchall(): if (federation == None): print("WARNING: No valid response:", blocker); + elif "error" in federation: + print("WARNING: API returned error:", federation["error"]) else: for peer in federation: - # NOISY-DEBUG: print("DEBUG: peer(),[]:", len(peer), type(peer)) - if (isinstance(peer, str) and peer == "error"): - print("WARNING: Cannot continue, maybe authentication required?", blocker) - break - blocked = peer["domain"].lower() # NOISY-DEBUG: print("DEBUG: BEFORE-blocked:", blocked) blocked = fba.tidyup(blocked) -- 2.39.2