]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 11 Jun 2023 17:25:49 +0000 (19:25 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 11 Jun 2023 17:25:49 +0000 (19:25 +0200)
- need to catch exceptions here so more instances can be added with
  software=None

fba/instances.py
fba/networks/pleroma.py

index d29260703cc5104cce03e89c7a7e049766740394..e7a5bd24ef876bb5a9048623433d44b5cd3c1c40 100644 (file)
@@ -25,6 +25,7 @@ from fba import blacklist
 from fba import cache
 from fba import fba
 from fba import federation
+from fba import network
 
 # Found info from node, such as nodeinfo URL, detection mode that needs to be
 # written to database. Both arrays must be filled at the same time or else
@@ -195,8 +196,12 @@ def add(domain: str, origin: str, command: str, path: str = None):
     elif domain.find("/profile/") > 0 or domain.find("/users/") > 0:
         raise Exception(f"domain='{domain}' is a single user")
 
-    # DEBUG: print("DEBUG: domain,origin,command,path:", domain, origin, command, path)
-    software = federation.determine_software(domain, path)
+    software = None
+    try:
+        # DEBUG: print("DEBUG: domain,origin,command,path:", domain, origin, command, path)
+        software = federation.determine_software(domain, path)
+    except network.exceptions as exception:
+        print(f"WARNING Exception '{type(exception)}' during determining software type")
 
     # DEBUG: print("DEBUG: Determined software:", software)
     if software == "lemmy" and domain.find("/c/") > 0:
index d024f1d4e7416a4f0d7d3ed7303aed3662c462ba..ade05924bbebd80d9691bee356d929eaa2550d87 100644 (file)
@@ -46,7 +46,11 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
 
     # Blocks
     blockdict = list()
-    rows = federation.fetch_nodeinfo(domain, nodeinfo_url)
+    rows = None
+    try:
+        rows = federation.fetch_nodeinfo(domain, nodeinfo_url)
+    except network.exceptions as exception:
+        print(f"WARNING: Exception '{type(exception)}' during fetching nodeinfo")
 
     if rows is None:
         print("WARNING: Could not fetch nodeinfo from domain:", domain)
@@ -118,6 +122,9 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
 
                     # DEBUG: print("DEBUG: Looking up instance by domain:", blocked)
                     if not instances.is_registered(blocked):
+                        # Commit changes
+                        fba.connection.commit()
+
                         # DEBUG: print(f"DEBUG: Domain blocked='{blocked}' wasn't found, adding ..., domain='{domain}',origin='{origin}',nodeinfo_url='{nodeinfo_url}'")
                         instances.add(blocked, domain, inspect.currentframe().f_code.co_name, nodeinfo_url)
 
@@ -201,7 +208,7 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
                     print(f"WARNING: blocked='{blocked}' is a reversed .arpa domain and should not be used generally.")
                     continue
                 elif not instances.is_registered(blocked):
-                    # DEBUG: print(f"DEBUG: Domain blocked='{blocked}' wasn't found, adding ..., domain='{domain}',origin='{origin}',nodeinfo_url='{nodeinfo_url}'")
+                    # DEBUG: print(f"DEBUG: Domain blocked='{blocked}' wasn't found, adding ..., domain='{domain}',origin='{origin}',nodein
                     instances.add(blocked, domain, inspect.currentframe().f_code.co_name, nodeinfo_url)
 
                 # DEBUG: print(f"DEBUG: Updating block reason: reason='{reason}',domain='{domain}',blocked='{blocked}',block_level='{block_level}'")