From de591f6f7326fa85a699f59a2adf2c785342faaa Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 21 May 2023 16:59:12 +0200 Subject: [PATCH] Continued: - res.reason is just a text respresentation of the code --- fba.py | 8 +++----- fetch_instances.py | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/fba.py b/fba.py index 93a5de8..c48ac88 100644 --- a/fba.py +++ b/fba.py @@ -57,12 +57,11 @@ def update_last_blocked(domain: str): sys.exit(255) def update_last_error(domain: str, res: any): - # NOISY-DEBUG: print("DEBUG: domain,res.status_code", domain, res.status_code) - + # NOISY-DEBUG: print("DEBUG: domain,res.status_code:", domain, res.status_code, res.reason) try: c.execute("UPDATE instances SET last_status_code = ?, last_error_details = ?, last_updated = ? WHERE domain = ?", [ res.status_code, - res.text, + res.reason, time.time(), domain ]) @@ -73,7 +72,6 @@ def update_last_error(domain: str, res: any): def update_last_nodeinfo(domain: str): # NOISY-DEBUG: print("DEBUG: Updating last_nodeinfo for domain:", domain) - try: c.execute("UPDATE instances SET last_nodeinfo = ?, last_updated = ? WHERE domain = ?", [ time.time(), @@ -108,8 +106,8 @@ def get_peers(domain: str) -> list: return peers def post_json_api(domain: str, path: str, data: str) -> list: + # NOISY-DEBUG: print("DEBUG: Sending POST to domain,path,data:", domain, path, data) try: - # NOISY-DEBUG: print("DEBUG: Sending POST to domain,path,data:", domain, path, data) res = reqto.post(f"https://{domain}{path}", data=data, headers=headers, timeout=config["timeout"]) if not res.ok or res.status_code >= 400: diff --git a/fetch_instances.py b/fetch_instances.py index 4285336..5a9f534 100644 --- a/fetch_instances.py +++ b/fetch_instances.py @@ -55,7 +55,7 @@ fetch_instances(instance, None) # Loop through some instances fba.c.execute( - "SELECT domain FROM instances WHERE software IN ('pleroma', 'mastodon', 'friendica', 'misskey', 'gotosocial') AND (software IS NULL OR last_nodeinfo IS NULL OR last_nodeinfo < ?) ORDER BY rowid DESC", [time.time() - fba.config["recheck_instance"]] + "SELECT domain FROM instances WHERE software IN ('pleroma', 'mastodon', 'friendica', 'misskey', 'gotosocial') AND (last_nodeinfo IS NULL OR last_nodeinfo < ?) ORDER BY rowid DESC", [time.time() - fba.config["recheck_instance"]] ) for instance in fba.c.fetchall(): -- 2.39.5