]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Thu, 15 Jun 2023 22:29:01 +0000 (00:29 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 15 Jun 2023 22:29:01 +0000 (00:29 +0200)
- if software is (still) None, then it needs to be determined, not otherwise
  (logic error)
- commented out some DEBUG lines

fba/fba.py
fba/federation.py
fba/models/instances.py

index 1c7e973d80fe4615bd1444fc15fb8564cd6e2315..b175e57547aa6ebcd47d221e5ab19e3643571e2e 100644 (file)
@@ -62,9 +62,9 @@ def fetch_url(url: str, headers: dict, timeout: tuple) -> requests.models.Respon
     # Invoke other function, avoid trailing ?
     # DEBUG: print(f"DEBUG: components[{type(components)}]={components}")
     if components.query != "":
-        response = network.fetch_response(components.hostname, f"{components.path}?{components.query}", headers, timeout)
+        response = network.fetch_response(components.netloc, f"{components.path}?{components.query}", headers, timeout)
     else:
-        response = network.fetch_response(components.hostname, f"{components.path}", headers, timeout)
+        response = network.fetch_response(components.netloc, f"{components.path}", headers, timeout)
 
     # DEBUG: print(f"DEBUG: response[]='{type(response)}' - EXXIT!")
     return response
index 17fe0ad52f204651eba76b20226a4770b97ff8f5..2d0b6d7c25d0eaf4a302e8a6b6d57fc2c61d3950 100644 (file)
@@ -61,7 +61,8 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path:
         try:
             software = determine_software(domain, path)
         except network.exceptions as exception:
-            print(f"DEBUG: Exception '{type(exception)}' during determining software type")
+            # DEBUG: print(f"DEBUG: Exception '{type(exception)}' during determining software type")
+            pass
 
         # DEBUG: print(f"DEBUG: Determined software='{software}' for domain='{domain}'")
     elif not isinstance(software, str):
@@ -77,8 +78,8 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path:
         raise ValueError(f"domain='{domain}' is not a valid domain")
 
     if not instances.is_registered(domain.split("/")[0]):
-        # DEBUG: print("DEBUG: Adding new domain:", domain, origin)
-        instances.add(domain, origin, command, path)
+        # DEBUG: print(f"DEBUG: Adding new domain='{domain}',origin='{origin}',command='{command}',path='{path}',software='{software}'")
+        instances.add(domain, origin, command, path, software)
 
     # DEBUG: print(f"DEBUG: Updating last_instance_fetch for domain='{domain}' ...")
     instances.set_last_instance_fetch(domain)
@@ -122,7 +123,7 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path:
             print(f"WARNING: instance='{instance}' is a reversed .arpa domain and should not be used generally.")
             continue
         elif instance.find("/profile/") > 0 or instance.find("/users/") > 0:
-            print(f"DEBUG: instance='{instance}' is a link to a single user profile - SKIPPED!")
+            # DEBUG: print(f"DEBUG: instance='{instance}' is a link to a single user profile - SKIPPED!")
             continue
         elif not instances.is_registered(instance):
             # DEBUG: print("DEBUG: Adding new instance:", instance, domain)
@@ -523,7 +524,7 @@ def find_domains(tag: bs4.element.Tag) -> list:
             print(f"WARNING: domain='{domain}' is not a valid domain - SKIPPED!")
             continue
 
-        # DEBUG: print(f"DEBUG: Adding domain='{domain}' ...")
+        # DEBUG: print(f"DEBUG: Adding domain='{domain}',reason='{reason}' ...")
         domains.append({
             "domain": domain,
             "reason": reason,
index 7644566a2bec7ebff63799e4e7db4d264d11c0a2..49288083b36479d5a6d737fa059bdab025cad3e9 100644 (file)
@@ -183,7 +183,7 @@ def add(domain: str, origin: str, command: str, path: str = None, software: str
     elif domain.find("/profile/") > 0 or domain.find("/users/") > 0 or (software == "lemmy" and domain.find("/c/") > 0):
         raise Exception(f"domain='{domain}' is a single user")
 
-    if isinstance(software, str):
+    if software is None:
         try:
             # DEBUG: print("DEBUG: domain,origin,command,path:", domain, origin, command, path)
             software = federation.determine_software(domain, path)