From 22b46975111d2da796a6065bddedd1c7e6335a01 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 16 Jun 2023 00:29:01 +0200 Subject: [PATCH] Continued: - if software is (still) None, then it needs to be determined, not otherwise (logic error) - commented out some DEBUG lines --- fba/fba.py | 4 ++-- fba/federation.py | 11 ++++++----- fba/models/instances.py | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/fba/fba.py b/fba/fba.py index 1c7e973..b175e57 100644 --- a/fba/fba.py +++ b/fba/fba.py @@ -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 diff --git a/fba/federation.py b/fba/federation.py index 17fe0ad..2d0b6d7 100644 --- a/fba/federation.py +++ b/fba/federation.py @@ -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, diff --git a/fba/models/instances.py b/fba/models/instances.py index 7644566..4928808 100644 --- a/fba/models/instances.py +++ b/fba/models/instances.py @@ -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) -- 2.39.5