From 3f2dcadf0c42b66f486d82fe60190f65897f0edf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 20 Nov 2023 00:06:40 +0100 Subject: [PATCH] Continued: - empty strings are not accepted as block reasons, better 'None' instead --- fba/boot.py | 2 +- fba/models/blocks.py | 2 ++ fba/models/instances.py | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/fba/boot.py b/fba/boot.py index dddc80f..9e8e91c 100644 --- a/fba/boot.py +++ b/fba/boot.py @@ -124,7 +124,7 @@ def init_parser(): ### Fetch blocks from oliphant's GIT repository ### parser = subparser_command.add_parser( "fetch_oliphant", - help="Fetches CSV files (block recommendations) for more possible instances to disover", + help="Fetches CSV files from GIT generated by Oliphant 'member instances'.", ) parser.set_defaults(command=commands.fetch_oliphant) parser.add_argument("--domain", help="Instance name (aka. domain) to check") diff --git a/fba/models/blocks.py b/fba/models/blocks.py index 16c7027..1b61887 100644 --- a/fba/models/blocks.py +++ b/fba/models/blocks.py @@ -139,6 +139,8 @@ def add(blocker: str, blocked: str, reason: str, block_level: str): raise Exception(f"blocker='{blocker}' is blacklisted but function invoked") elif blacklist.is_blacklisted(blocked): raise Exception(f"blocked='{blocked}' is blacklisted but function invoked") + elif reason is not None and reason == "": + raise Exception(f"blocker='{blocker}',blocked='{blocked}',block_level='{block_level}' has empty (not 'None') block reason set") if reason is not None: # Maybe needs cleaning diff --git a/fba/models/instances.py b/fba/models/instances.py index f8e28b3..8bc81c8 100644 --- a/fba/models/instances.py +++ b/fba/models/instances.py @@ -202,6 +202,8 @@ def add(domain: str, origin: str, command: str, path: str = None, software: str logger.debug("Determined software='%s'", software) if software == "lemmy" and domain.find("/c/") > 0: domain = domain.split("/c/")[0] + + logger.debug("domain='%s' - LEMMY /c/ !", domain) if is_registered(domain): logger.warning("domain='%s' already registered after cutting off user part. - EXIT!", domain) return @@ -551,6 +553,7 @@ def translate_idnas(rows: list, column: str): logger.warning("Deleting row[%s]='%s' as translated='%s' already exist", column, row[column], translated) database.cursor.execute(f"DELETE FROM instances WHERE {column} = ? LIMIT 1", [row[column]]) else: + logger.debug("Updating row[%s]='%s' to translated='%s' ...", column, row[column], translated) database.cursor.execute(f"UPDATE instances SET {column} = ? WHERE {column} = ? LIMIT 1", [translated, row[column]]) logger.debug("Invoking commit() ...") -- 2.39.5