From 7aa9e4dc66c425a6e3c7e44ba1ae9a43579cfb9e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 25 May 2023 23:34:57 +0200 Subject: [PATCH] Continued: - ops, need to include [domain] for nodeinfos array, too - more flexible check if a domain has pending nodeinfos --- fba.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/fba.py b/fba.py index 6ccaf13..98c56dc 100644 --- a/fba.py +++ b/fba.py @@ -471,8 +471,8 @@ def fetch_generator_from_path(domain: str, path: str = "/") -> str: if isinstance(tag, bs4.element.Tag): # NOISY-DEBUG: print("DEBUG: Found generator meta tag: ", domain) software = tidyup(tag.get("content")) - # NOISY-DEBUG: print(f"DEBUG: software='{software}'") - nodeinfos["detection_mode"] = "GENERATOR" + # NOISY-DEBUG: pprint(f"DEBUG: software='{software}', setting detection mode ...") + nodeinfos["detection_mode"][domain] = "GENERATOR" remove_pending_error(domain) except BaseException as e: @@ -482,6 +482,7 @@ def fetch_generator_from_path(domain: str, path: str = "/") -> str: # NOISY-DEBUG: print(f"DEBUG: software[]={type(software)}") if type(software) is str and software == "": + print(f"DEBUG: Corrected empty string to None for software of domain='{domain}'") software = None elif type(software) is str and "." in software: # NOISY-DEBUG: print(f"DEBUG: software='{software}' may contain a version number, domain='{domain}', removing it ...") @@ -637,7 +638,7 @@ def add_instance(domain: str, origin: str, originator: str): software = determine_software(domain) # NOISY-DEBUG: print("DEBUG: Determined software:", software) - print(f"INFO: Adding new instance {domain} (origin: {origin})") + print(f"INFO: Adding instance {domain} (origin: {origin})") try: cursor.execute( "INSERT INTO instances (domain, origin, originator, hash, software, first_seen) VALUES (?, ?, ?, ?, ?, ?)", @@ -651,11 +652,15 @@ def add_instance(domain: str, origin: str, originator: str): ), ) - if domain in nodeinfos["nodeinfo_url"]: - # NOISY-DEBUG # NOISY-DEBUG: print("DEBUG: domain has pending nodeinfo being updated:", domain) - update_nodeinfos(domain) - remove_pending_error(domain) - elif domain in pending_errors: + for key in nodeinfos: + # NOISY-DEBUG: pprint(f"DEBUG: key='{key}',domain='{domain}',nodeinfos[key]={nodeinfos[key]}") + if domain in nodeinfos[key]: + # NOISY-DEBUG: pprint(f"DEBUG: domain='{domain}' has pending nodeinfo being updated ...") + update_nodeinfos(domain) + remove_pending_error(domain) + break + + if domain in pending_errors: # NOISY-DEBUG: print("DEBUG: domain has pending error being updated:", domain) update_last_error(domain, pending_errors[domain]) remove_pending_error(domain) -- 2.39.5