From: Roland Häder Date: Mon, 13 Jan 2025 02:57:45 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f672652fc857e931699ea74a4929bd0f71f86d34;p=fba.git Continued: - improved logging message - also search args.software in column original_software --- diff --git a/fba/commands.py b/fba/commands.py index 19418a0..c120021 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -296,7 +296,7 @@ def fetch_blocks(args: argparse.Namespace) -> int: elif args.software not in [None, ""]: # Re-check single software logger.debug("Querying database for args.software='%s' ...", args.software) - database.cursor.execute("SELECT domain, software, origin, nodeinfo_url FROM instances WHERE software = ? ORDER BY last_blocked ASC, total_blocks DESC", [args.software]) + database.cursor.execute("SELECT domain, software, origin, nodeinfo_url FROM instances WHERE software = ? OR original_software = ? ORDER BY last_blocked ASC, total_blocks DESC", [args.software, args.software]) elif args.only_none: # Check only entries with total_blocked=None database.cursor.execute("SELECT domain, software, origin, nodeinfo_url FROM instances WHERE software IN ('pleroma', 'mastodon', 'lemmy', 'friendica', 'misskey', 'piefed', 'typecho') AND nodeinfo_url IS NOT NULL AND total_blocks IS NULL ORDER BY last_blocked ASC, total_blocks DESC") @@ -1356,7 +1356,7 @@ def recheck_obfuscation(args: argparse.Namespace) -> int: database.cursor.execute("SELECT domain, software, nodeinfo_url FROM instances WHERE domain = ? LIMIT 1", [args.domain]) elif isinstance(args.software, str) and args.software != "" and validators.domain(args.software, rfc_2782=True) == args.software: logger.debug("Fetching records for args.software='%s' ...", args.software) - database.cursor.execute("SELECT domain, software, nodeinfo_url FROM instances WHERE (has_obfuscation = 1 OR has_obfuscation IS NULL) AND software = ? ORDER BY last_blocked ASC", [args.software]) + database.cursor.execute("SELECT domain, software, nodeinfo_url FROM instances WHERE (has_obfuscation = 1 OR has_obfuscation IS NULL) AND software = ? OR original_software = ? ORDER BY last_blocked ASC", [args.software, args.software]) elif args.no_obfuscation: logger.debug("Fetching records with no obfuscation of blocked domain ...") database.cursor.execute("SELECT domain, software, nodeinfo_url FROM instances WHERE has_obfuscation = 0 AND total_blocks > 0 AND software IS NOT NULL ORDER BY last_blocked ASC") @@ -1585,7 +1585,7 @@ def update_nodeinfo(args: argparse.Namespace) -> int: database.cursor.execute("SELECT domain, software FROM instances WHERE domain = ? LIMIT 1", [args.domain]) elif args.software not in [None, ""]: logger.info("Fetching domains for args.software='%s'", args.software) - database.cursor.execute("SELECT domain, software FROM instances WHERE software = ? ORDER BY last_updated ASC", [args.software]) + database.cursor.execute("SELECT domain, software FROM instances WHERE software = ? OR original_software = ? ORDER BY last_updated ASC", [args.software, args.software]) elif args.mode not in [None, ""]: logger.info("Fetching domains for args.mode='%s'", args.mode.upper()) database.cursor.execute("SELECT domain, software FROM instances WHERE detection_mode = ? ORDER BY last_updated ASC", [args.mode]) diff --git a/fba/models/instances.py b/fba/models/instances.py index c3e347c..3bc3d95 100644 --- a/fba/models/instances.py +++ b/fba/models/instances.py @@ -149,9 +149,8 @@ def update(domain: str) -> None: sql_string += f" {key} = ?," updated = updated + 1 + # Log concated SQL string logger.debug("sql_string(%d)='%s',updated=%d", len(sql_string), sql_string, updated) - if sql_string == "" or updated == 0: - raise ValueError(f"No fields have been set, but function invoked, domain='{domain}'") # Set last_updated to current timestamp fields.append(time.time()) @@ -175,7 +174,7 @@ def update(domain: str) -> None: logger.debug("Deleting _pending for domain='%s'", domain) for key in _pending: - logger.debug("domain='%s',key='%s'", domain, key) + logger.debug("domain='%s',_pend[%s]()=%d", domain, key, len(_pending[key])) if domain in _pending[key]: logger.debug("Deleting key='%s',domain='%s' ...", key, domain) del _pending[key][domain] diff --git a/fba/networks/lemmy.py b/fba/networks/lemmy.py index df912f1..952e27e 100644 --- a/fba/networks/lemmy.py +++ b/fba/networks/lemmy.py @@ -162,10 +162,8 @@ def fetch_blocks(domain: str) -> list: for container in containers: logger.debug("container[]='%s'", type(container)) for header in container.find_all(["h2", "h3", "h4", "h5"]): - content = header logger.debug("header[%s]='%s' - BEFORE!", type(header), header) - if header is not None: - content = str(header.contents[0]) + content = header if header is None else str(header.contents[0]) logger.debug("content[%s]='%s' - AFTER!", type(content), content) if content in [None, ""]: