From: Roland Häder Date: Tue, 12 Sep 2023 10:13:58 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c59899c4c3f69c6935cb784b5d4bc8a675968258;p=fba.git Continued: - commit after each CSV row being handled - tpzo fixed in module name - always add domain to domains list --- diff --git a/fba/commands.py b/fba/commands.py index f62de80..64125d9 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -319,7 +319,7 @@ def fetch_blocks(args: argparse.Namespace) -> int: # c.s isn't part of oliphant's "hidden" blocklists if blocker == "chaos.social" or software_helper.is_relay(software) or blocklists.has(blocker): - logger.debug("Skipping blocker='%s', run ./fba.py fetch_cs or fetch_oliphant instead!", blocker) + logger.debug("Skipping blocker='%s', run ./fba.py fetch_cs, fetch_oliphant, fetch_csv instead!", blocker) continue logger.debug("Invoking federation.fetch_blocks(%s) ...", blocker) diff --git a/fba/helpers/processing.py b/fba/helpers/processing.py index 5f4f23e..0face7f 100644 --- a/fba/helpers/processing.py +++ b/fba/helpers/processing.py @@ -165,11 +165,11 @@ def csv_block(blocker: str, url: str, command: str): severity = "reject" if "reason" in row: - reason = tidup.reason(row["reason"]) if row["reason"] != None and row["reason"] != "" else None + reason = tidyup.reason(row["reason"]) if row["reason"] != None and row["reason"] != "" else None elif "comment" in row: - reason = tidup.reason(row["comment"]) if row["comment"] != None and row["comment"] != "" else None + reason = tidyup.reason(row["comment"]) if row["comment"] != None and row["comment"] != "" else None elif "Comment" in row: - reason = tidup.reason(row["Comment"]) if row["Comment"] != None and row["Comment"] != "" else None + reason = tidyup.reason(row["Comment"]) if row["Comment"] != None and row["Comment"] != "" else None else: logger.debug("row='%s' has no reason/comment key provided", row) @@ -202,6 +202,9 @@ def csv_block(blocker: str, url: str, command: str): domain = utils.deobfuscate(domain, blocker) logger.debug("domain='%s' - AFTER!", domain) + logger.debug("Marking domain='%s' as handled", domain) + domains.append(domain) + if not validators.domain(domain): logger.debug("domain='%s' is not a valid domain - SKIPPED!") continue @@ -212,9 +215,6 @@ def csv_block(blocker: str, url: str, command: str): logger.debug("blocker='%s' has already blocked domain='%s' with severity='%s' - SKIPPED!", blocker, domain, severity) continue - logger.debug("Marking domain='%s' as handled", domain) - domains.append(domain) - logger.debug("Processing domain='%s',blocker='%s',command='%s' ...", domain, blocker, command) processed = instance(domain, blocker, command) logger.debug("processed='%s'", processed) @@ -231,8 +231,11 @@ def csv_block(blocker: str, url: str, command: str): if reject_reports: block(blocker, domain, None, "reject_reports") + logger.debug("Invoking commit() ...") + database.connection.commit() + logger.debug("blocker='%s'", blocker) - if not blocklists.has(blocker): + if blocklists.has(blocker): logger.debug("Invoking instances.set_total_blocks(%s, domains()=%d) ...", blocker, len(domains)) instances.set_total_blocks(blocker, domains) @@ -241,9 +244,6 @@ def csv_block(blocker: str, url: str, command: str): logger.debug("Flushing updates for blocker='%s' ...", blocker) instances.update(blocker) - logger.debug("Invoking commit() ...") - database.connection.commit() - logger.debug("config.get(bot_enabled)='%s',blockdict()=%d", config.get("bot_enabled"), len(blockdict)) if config.get("bot_enabled") and len(blockdict) > 0: logger.info("Sending bot POST for blocker='%s',blockdict()=%d ...", blocker, len(blockdict))