From 40fa5bf62f9214a44fb2646132cdf5858d3efc85 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 24 May 2023 07:23:50 +0200 Subject: [PATCH] Continued: - if fetching nodeinfo was successful, then clear any status codes and error messages for this instance - also tidyup() found instance, some are invalid :-( --- fba.py | 11 +++++++---- fetch_instances.py | 9 +++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/fba.py b/fba.py index aa9c1ab..79adabf 100644 --- a/fba.py +++ b/fba.py @@ -104,11 +104,10 @@ def update_nodeinfos(domain: str): fields.append(nodeinfos[key][domain]) sql_string += f" {key} = ?," - sql_string = sql_string[:-1] fields.append(domain) # NOISY-DEBUG: print(f"DEBUG: sql_string='{sql_string}',fields()={len(fields)}") - sql = "UPDATE instances SET" + sql_string + " WHERE domain = ? LIMIT 1" + sql = "UPDATE instances SET" + sql_string + " last_status_code = NULL, last_error_details = NULL WHERE domain = ? LIMIT 1" # NOISY-DEBUG: print("DEBUG: sql:", sql) try: @@ -501,8 +500,12 @@ 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) - - if domain in pending_errors: + try: + # Prevent updating any pending errors, nodeinfo was found + del pending_errors[domain] + except: + pass + elif domain in pending_errors: # NOISY-DEBUG: print("DEBUG: domain has pending error being updated:", domain) update_last_error(domain, pending_errors[domain]) del pending_errors[domain] diff --git a/fetch_instances.py b/fetch_instances.py index 635cc1c..6b8a8d8 100644 --- a/fetch_instances.py +++ b/fetch_instances.py @@ -27,9 +27,14 @@ def fetch_instances(domain: str, origin: str, software: str): print(f"INFO: Checking {len(peerlist)} instances from {domain} ...") for instance in peerlist: - instance = instance.lower() + # NOISY-DEBUG: print("DEBUG: BEFORE instance:", instance) + instance = fba.tidyup(instance) + # NOISY-DEBUG: print("DEBUG: AFTER instance:", instance) - if not validators.domain(instance): + if instance == "": + print("WARNING: Empty instance after tidyup(), domain:", domain) + continue + elif not validators.domain(instance): print("WARNING: Bad instance name,domain:", instance, domain) continue elif fba.is_blacklisted(instance): -- 2.39.5