From: Roland Häder Date: Fri, 10 Jan 2025 08:15:04 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e62ad492d666b8b5296e673e947e691e33e68c71;p=fba.git Continued: - added commented out debug lines --- diff --git a/fba/helpers/cache.py b/fba/helpers/cache.py index ecdb3fc..8299d28 100644 --- a/fba/helpers/cache.py +++ b/fba/helpers/cache.py @@ -17,13 +17,12 @@ import logging import sqlite3 -logging.basicConfig(level=logging.INFO) -logger = logging.getLogger(__name__) - # Cache for redundant SQL queries _cache = {} -##### Cache ##### +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger(__name__) +#logger.setLevel(logging.DEBUG) def key_exists(key: str) -> bool: logger.debug("key='%s' - CALLED!", key) diff --git a/fba/helpers/config.py b/fba/helpers/config.py index 091b53a..5f6f0aa 100644 --- a/fba/helpers/config.py +++ b/fba/helpers/config.py @@ -18,13 +18,14 @@ import logging import json import sys -logging.basicConfig(level=logging.INFO) -logger = logging.getLogger(__name__) - # Private configration array, DO NOT access this directly. Please invoke # config.get("foo") instead _config = {} +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger(__name__) +#logger.setLevel(logging.DEBUG) + with open("config.json") as f: logger.debug("Loading configuration file ...") _config = json.loads(f.read()) diff --git a/fba/helpers/cookies.py b/fba/helpers/cookies.py index b23e644..edfbd18 100644 --- a/fba/helpers/cookies.py +++ b/fba/helpers/cookies.py @@ -19,12 +19,13 @@ import logging from fba.helpers import blacklist from fba.helpers import domain as domain_helper -logging.basicConfig(level=logging.INFO) -logger = logging.getLogger(__name__) - # Cookies storage _cookies = {} +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger(__name__) +#logger.setLevel(logging.DEBUG) + def store(domain: str, cookies: dict): logger.debug("domain='%s',cookies()=%d - CALLED!", domain, len(cookies)) domain_helper.raise_on(domain) diff --git a/fba/helpers/dicts.py b/fba/helpers/dicts.py index cd9ccbd..7142b3f 100644 --- a/fba/helpers/dicts.py +++ b/fba/helpers/dicts.py @@ -17,6 +17,7 @@ import logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) +#logger.setLevel(logging.DEBUG) def has_key(lists: list, key: str, value: any) -> bool: logger.debug("lists()=%d,key='%s',value[]='%s' - CALLED!", len(lists), key, type(value)) diff --git a/fba/helpers/domain.py b/fba/helpers/domain.py index 7d3ad06..224b590 100644 --- a/fba/helpers/domain.py +++ b/fba/helpers/domain.py @@ -28,6 +28,7 @@ from fba.models import instances logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) +#logger.setLevel(logging.DEBUG) def raise_on(domain: str) -> None: logger.debug("domain='%s' - CALLED!", domain) diff --git a/fba/helpers/json.py b/fba/helpers/json.py index 6d0454c..b862d73 100644 --- a/fba/helpers/json.py +++ b/fba/helpers/json.py @@ -21,6 +21,7 @@ import requests logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) +#logger.setLevel(logging.DEBUG) def is_json_response(response: requests.models.Response) -> bool: logger.debug("response[]='%s' - CALLED!", type(response)) @@ -46,7 +47,10 @@ def from_response(response: requests.models.Response) -> any: logger.warning("response.headers[content-type]='%s' is not a JSON type, below json() invocation may raise an exception", response.headers.get("content-type")) data = list() - if response.text.strip() != "": + raw = response.text.strip() + + logger.debug("raw()=%d", len(raw)) + if raw != "": logger.debug("response.text()=%d is not empty, invoking response.json() ...", len(response.text)) try: data = response.json() diff --git a/fba/helpers/locking.py b/fba/helpers/locking.py index c507f72..809d153 100644 --- a/fba/helpers/locking.py +++ b/fba/helpers/locking.py @@ -20,13 +20,14 @@ import sys import tempfile import zc.lockfile -logging.basicConfig(level=logging.INFO) -logger = logging.getLogger(__name__) - # Lock file lockfile = tempfile.gettempdir() + '/fba.lock' LOCK = None +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger(__name__) +#logger.setLevel(logging.DEBUG) + def acquire() -> None: global LOCK logger.debug("CALLED!") diff --git a/fba/helpers/processing.py b/fba/helpers/processing.py index b1f9a8e..0bed763 100644 --- a/fba/helpers/processing.py +++ b/fba/helpers/processing.py @@ -36,6 +36,7 @@ from fba.models import instances logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) +#logger.setLevel(logging.DEBUG) def instance(blocked: str, blocker: str, command: str, force: bool = False) -> bool: logger.debug("blocked='%s',blocker='%s',command='%s',force='%s' - CALLED!", blocked, blocker, command, force) diff --git a/fba/helpers/software.py b/fba/helpers/software.py index baac34c..d6577e9 100644 --- a/fba/helpers/software.py +++ b/fba/helpers/software.py @@ -21,9 +21,6 @@ from functools import lru_cache from fba.helpers import tidyup from fba.helpers import version -logging.basicConfig(level=logging.INFO) -logger = logging.getLogger(__name__) - # A list of relay software relays = [ "activityrelay", @@ -98,6 +95,10 @@ _pleroma_aliases = [ "moon-eyed" ] +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger(__name__) +#logger.setLevel(logging.DEBUG) + @lru_cache def alias(software: str) -> str: logger.debug("software='%s'- CALLED!", software) diff --git a/fba/helpers/tidyup.py b/fba/helpers/tidyup.py index acd8bc6..a249926 100644 --- a/fba/helpers/tidyup.py +++ b/fba/helpers/tidyup.py @@ -18,6 +18,7 @@ import re logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) +#logger.setLevel(logging.DEBUG) def reason(string: str) -> str: logger.debug("string='%s' - CALLED!", string) diff --git a/fba/helpers/version.py b/fba/helpers/version.py index b6f7c64..3af5456 100644 --- a/fba/helpers/version.py +++ b/fba/helpers/version.py @@ -18,11 +18,8 @@ import re from fba.helpers import software as software_helper -logging.basicConfig(level=logging.INFO) -logger = logging.getLogger(__name__) - # Pattern instance for version numbers -patterns = [ +_patterns = [ # semantic version number (with v|V) prefix) re.compile(r"^(?Pv|V{0,1})(\.{0,1})(?P0|[1-9]\d*)\.(?P0+|[1-9]\d*)(\.(?P0+|[1-9]\d*)(?:-(?P(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)?$"), # non-sematic, e.g. 1.2.3.4 @@ -33,6 +30,10 @@ patterns = [ re.compile("^[a-f0-9]{7}$"), ] +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger(__name__) +#logger.setLevel(logging.DEBUG) + def remove(software: str) -> str: logger.debug("software='%s' - CALLED!", software) @@ -61,8 +62,8 @@ def remove(software: str) -> str: return software match = None - logger.debug("Checking %d patterns ...", len(patterns)) - for pattern in patterns: + logger.debug("Checking %d patterns ...", len(_patterns)) + for pattern in _patterns: # Run match() match = pattern.match(version)