]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Fri, 2 Jun 2023 22:36:43 +0000 (00:36 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 2 Jun 2023 22:36:43 +0000 (00:36 +0200)
- log every single problem

fetch_bkali.py

index b245febfd25bfd4e286f10044c37fd42f49b0626..acfe7c6057ee8f2f6eb58f7fba3f3a62440d3a2d 100755 (executable)
@@ -29,23 +29,30 @@ try:
     }))
 
     # DEBUG: print(f"DEBUG: fetched({len(fetched)})[]='{type(fetched)}'")
-    if len(fetched) > 0 and "data" in fetched and "nodeinfo" in fetched["data"]:
-        for entry in fetched["data"]["nodeinfo"]:
-            # DEBUG: print(f"DEBUG: entry['{type(entry)}']='{entry}'")
-            if not "domain" in entry:
-                print(f"WARNING: entry does not contain 'domain' - SKIPPED!")
-                continue
-            elif not validators.domain(entry["domain"]):
-                print(f"WARNING: domain='{entry['domain']}' is not a valid domain - SKIPPED!")
-                continue
-            elif fba.is_blacklisted(entry["domain"]):
-                # DEBUG: print(f"DEBUG: domain='{entry['domain']}' is blacklisted - SKIPPED!")
-                continue
-            elif fba.is_instance_registered(entry["domain"]):
-                # DEBUG: print(f"DEBUG: domain='{entry['domain']}' is already registered - SKIPPED!")
-                continue
-
-            domains.append(entry["domain"])
+    if len(fetched) == 0:
+        raise Exception("WARNING: Returned no records")
+    elif not "data" in fetched:
+        raise Exception(f"WARNING: fetched()={len(fetched)} does not contain element 'data'")
+    elif not "nodeinfo" in fetched["data"]:
+        raise Exception(f"WARNING: fetched()={len(fetched['data'])} does not contain element 'nodeinfo'")
+
+    for entry in fetched["data"]["nodeinfo"]:
+        # DEBUG: print(f"DEBUG: entry['{type(entry)}']='{entry}'")
+        if not "domain" in entry:
+            print(f"WARNING: entry does not contain 'domain' - SKIPPED!")
+            continue
+        elif not validators.domain(entry["domain"]):
+            print(f"WARNING: domain='{entry['domain']}' is not a valid domain - SKIPPED!")
+            continue
+        elif fba.is_blacklisted(entry["domain"]):
+            # DEBUG: print(f"DEBUG: domain='{entry['domain']}' is blacklisted - SKIPPED!")
+            continue
+        elif fba.is_instance_registered(entry["domain"]):
+            # DEBUG: print(f"DEBUG: domain='{entry['domain']}' is already registered - SKIPPED!")
+            continue
+
+        # DEBUG: print(f"DEBUG: Adding domain='{entry['domain']}' ...")
+        domains.append(entry["domain"])
 
 except BaseException as e:
     print(f"ERROR: Cannot fetch graphql,exception[{type(e)}]:'{str(e)}'")