import inspect
import json
import logging
-import numpy
+
+import argparse
import time
import urllib
+import numpy
-import argparse
import atoma
import bs4
import markdown
delete_sql = ", ".join([f"\'{pattern}\'" for pattern in deleted])
logger.debug("delete_sql='%s'", delete_sql)
- database.cursor.execute("DELETE FROM obfuscation WHERE pattern IN (%s)" % delete_sql)
+ database.cursor.execute(f"DELETE FROM obfuscation WHERE pattern IN ({delete_sql})")
logger.debug("Invoking commit() ...")
database.connection.commit()
logger.debug("software='%s'- CALLED!", software)
if not isinstance(software, str):
- raise TypError(f"software[]='{type(software)}' is not type 'str'")
+ raise TypeError(f"software[]='{type(software)}' is not type 'str'")
elif software == "":
raise ValueError("Parameter 'software' is empty")
logger.debug("response.ok='%s',response.status_code=%d,response.text()=%d", response.ok, response.status_code, len(response.text))
if not response.ok or response.status_code > 200 or len(response.content) == 0:
logger.warning("Failed fetching url='%s': response.ok='%s',response.status_code=%d,response.content()=%d - EXIT!", url, response.ok, response.status_code, len(response.text))
- raise RuntimeException(f"response.ok='{response.ok}',response.status_code={response.status_code},response.content()={len(response.content)} is unexpected")
+ raise RuntimeError(f"response.ok='{response.ok}',response.status_code={response.status_code},response.content()={len(response.content)} is unexpected")
lines = response.content.decode("utf-8").splitlines()
logger.debug("Reading %d lines, dialect=unix ...", len(lines))
if reader is None:
logger.warning("Failed parsing response.content()=%d as CSV content", len(response.content))
- raise RuntimeException(f"reader is None after parsing {len(lines)} CSV lines")
+ raise RuntimeError(f"reader is None after parsing {len(lines)} CSV lines")
# Init rows from CSV reader
rows = list(reader)
domain_helper.raise_on(blocked)
if not isinstance(reason, str) and reason is not None:
- raise TypError(f"Parameter reason[]='{type(reason)}' has not expected type 'str'")
+ raise TypeError(f"Parameter reason[]='{type(reason)}' has not expected type 'str'")
elif not isinstance(block_level, str):
raise TypeError(f"Parameter block_level[]='{type(block_level)}' has not expected type 'str'")
elif block_level == "":
logger.warning("block[domain]='%s' has invalid block[digest]='%s' - SKIPPED!", block["domain"], block["digest"])
continue
- logger.debug("block[reason]='%s' - BEFORE!", row["block"])
+ logger.debug("block[reason]='%s' - BEFORE!", block["reason"])
reason = tidyup.reason(block["reason"]) if "reason" in block and block["reason"] not in [None, ""] else None
logger.debug("Appending domain='%s',block[domain]='%s',reason='%s',block_level='%s' ...", domain, block["domain"], reason, block_level)