From 8974b3961f4d9c9c28e299fb6009c349b700c2d2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 18 May 2023 04:24:10 +0200 Subject: [PATCH] Continued: - INFO level is okay here - in the end, variable 'reason' wasn't defined --- fetch_blocks.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/fetch_blocks.py b/fetch_blocks.py index 9ce2715..c11710e 100644 --- a/fetch_blocks.py +++ b/fetch_blocks.py @@ -14,7 +14,7 @@ for blocker, software in fba.c.fetchall(): blockdict = [] blocker = fba.tidyup(blocker) if software == "pleroma": - print("DEBUG: blocker:", blocker) + print("INFO: blocker:", blocker) try: # Blocks federation = reqto.get( @@ -26,7 +26,9 @@ for blocker, software in fba.c.fetchall(): **{"quarantined_instances": federation["quarantined_instances"]}} ).items(): for blocked in blocks: + print("DEBUG: BEFORE blocked:", blocked) blocked = fba.tidyup(blocked) + print("DEBUG: AFTER blocked:", blocked) if blocked == "": print("WARNING: blocked is empty after fba.tidyup():", blocker, block_level) @@ -38,15 +40,17 @@ for blocker, software in fba.c.fetchall(): "SELECT domain FROM instances WHERE domain LIKE ? ORDER BY rowid LIMIT 1", (blocked.replace("*", "_"),) ) searchres = fba.c.fetchone() + print("DEBUG: searchres[]:", type(searchres)) if searchres != None: blocked = searchres[0] + print("DEBUG: Looking up instance by domain:", blocked) fba.c.execute( "SELECT domain FROM instances WHERE domain = ?", (blocked,) ) if fba.c.fetchone() == None: - print("DEBUG: Hash wasn't found, adding:", blocked) + print("DEBUG: Domain wasn't found, adding:", blocked) fba.add_instance(blocked) timestamp = int(time.time()) @@ -58,8 +62,9 @@ for blocker, software in fba.c.fetchall(): block_level ), ) + if fba.c.fetchone() == None: - fba.block_instance(blocker, blocked, reason, block_level, timestamp, timestamp) + fba.block_instance(blocker, blocked, "unknown", block_level, timestamp, timestamp) if block_level == "reject": blockdict.append( @@ -106,7 +111,7 @@ for blocker, software in fba.c.fetchall(): except Exception as e: print("error:", e, blocker, software) elif software == "mastodon": - print("DEBUG: blocker:", blocker) + print("INFO: blocker:", blocker) try: # json endpoint for newer mastodongs try: @@ -214,7 +219,7 @@ for blocker, software in fba.c.fetchall(): except Exception as e: print("error:", e, blocker, software) elif software == "friendica" or software == "misskey": - print("DEBUG: blocker:", blocker) + print("INFO: blocker:", blocker) try: if software == "friendica": json = fba.get_friendica_blocks(blocker) @@ -277,7 +282,7 @@ for blocker, software in fba.c.fetchall(): except Exception as e: print("error:", e, blocker, software) elif software == "gotosocial": - print("DEBUG: blocker:", blocker) + print("INFO: blocker:", blocker) try: # Blocks federation = reqto.get( -- 2.39.5