]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 20 May 2023 11:00:09 +0000 (13:00 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 20 May 2023 11:00:09 +0000 (13:00 +0200)
- try block must be around software type checking, not the reqto.foo() call

fba.py

diff --git a/fba.py b/fba.py
index 5d59ad43a4130aa80385cb26fc322590d3397ad2..53ef74c688bbb6e420061f955ff28ce7a17cab62 100644 (file)
--- a/fba.py
+++ b/fba.py
@@ -110,26 +110,23 @@ def fetch_nodeinfo(domain: str) -> list:
 
     json = None
     for request in requests:
-        try:
-            # NOISY-DEBUG: print("DEBUG: Fetching request:", request)
-            res = reqto.get(request, headers=headers, timeout=5)
-
-            # NOISY-DEBUG: print("DEBUG: res.ok,res.json[]:", res.ok, type(res.json()))
-            if res.ok and res.json() is not None:
-                # NOISY-DEBUG: print("DEBUG: Success:", request)
-                json = res.json()
-                break
-            elif not res.ok or res.status_code >= 400:
-                # NOISY-DEBUG: print("DEBUG: Failed fetching nodeinfo from domain:", domain)
-                update_last_error(domain, res)
-                continue
-
-        except:
-            print("WARNING: Some error during get():", request)
+        # NOISY-DEBUG: print("DEBUG: Fetching request:", request)
+        res = reqto.get(request, headers=headers, timeout=5)
+
+        # NOISY-DEBUG: print("DEBUG: res.ok,res.json[]:", res.ok, type(res.json()))
+        if res.ok and res.json() is not None:
+            # NOISY-DEBUG: print("DEBUG: Success:", request)
+            json = res.json()
+            break
+        elif not res.ok or res.status_code >= 400:
+            # NOISY-DEBUG: print("DEBUG: Failed fetching nodeinfo from domain:", domain)
+            update_last_error(domain, res)
+            continue
 
     if json is None:
         print("WARNING: Failed fetching nodeinfo from domain:", domain)
 
+    # NOISY-DEBUG: print("DEBUG: Updating last_nodeinfo for domain:", domain)
     update_last_nodeinfo(domain)
 
     # NOISY-DEBUG: print("DEBUG: Returning json():", len(json))
@@ -138,21 +135,26 @@ def fetch_nodeinfo(domain: str) -> list:
 def determine_software(domain: str) -> str:
     # NOISY-DEBUG: print("DEBUG: Determining software for domain:", domain)
     software = None
-    json = fetch_nodeinfo(domain)
-    # NOISY-DEBUG: print("DEBUG: json():", len(json))
-
-    if json["software"]["name"] in ["akkoma", "rebased"]:
-        # NOISY-DEBUG: print("DEBUG: Setting pleroma:", domain, json["software"]["name"])
-        software = "pleroma"
-    elif json["software"]["name"] in ["hometown", "ecko"]:
-        # NOISY-DEBUG: print("DEBUG: Setting mastodon:", domain, json["software"]["name"])
-        software = "mastodon"
-    elif json["software"]["name"] in ["calckey", "groundpolis", "foundkey", "cherrypick"]:
-        # NOISY-DEBUG: print("DEBUG: Setting misskey:", domain, json["software"]["name"])
-        software = "misskey"
-    else:
-        # NOISY-DEBUG: print("DEBUG: Using name:", domain, json["software"]["name"])
-        software = json["software"]["name"]
+
+    try:
+        json = fetch_nodeinfo(domain)
+        # NOISY-DEBUG: print("DEBUG: json():", len(json))
+
+        if json["software"]["name"] in ["akkoma", "rebased"]:
+            # NOISY-DEBUG: print("DEBUG: Setting pleroma:", domain, json["software"]["name"])
+            software = "pleroma"
+        elif json["software"]["name"] in ["hometown", "ecko"]:
+            # NOISY-DEBUG: print("DEBUG: Setting mastodon:", domain, json["software"]["name"])
+            software = "mastodon"
+        elif json["software"]["name"] in ["calckey", "groundpolis", "foundkey", "cherrypick"]:
+            # NOISY-DEBUG: print("DEBUG: Setting misskey:", domain, json["software"]["name"])
+            software = "misskey"
+        else:
+            # NOISY-DEBUG: print("DEBUG: Using name:", domain, json["software"]["name"])
+            software = json["software"]["name"]
+
+    except:
+        print("WARNING: Could not determine software type:", domain)
 
     # NOISY-DEBUG: print("DEBUG: Returning domain,software:", domain, software)
     return software