]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 19 Nov 2023 23:28:01 +0000 (00:28 +0100)
committerRoland Häder <roland@mxchange.org>
Sun, 19 Nov 2023 23:28:01 +0000 (00:28 +0100)
- named parameters
- skip None type

fba/commands.py
fba/helpers/processing.py
fba/http/federation.py
fba/utils.py

index b000e3dcc980073a2ac4a34ba4b50d6dd876fefb..04a959d00ecb3b213189b62781a50099e992e685 100644 (file)
@@ -148,6 +148,9 @@ def fetch_pixelfed_api(args: argparse.Namespace) -> int:
             if "domain" not in row:
                 logger.warning("row='%s' does not contain element 'domain' - SKIPPED!", row)
                 continue
+            elif row["domain"] is None:
+                logger.debug("row[domain] is None - SKIPPED!")
+                continue
             elif row["domain"] == "":
                 logger.debug("row[domain] is empty - SKIPPED!")
                 continue
@@ -1639,8 +1642,8 @@ def fetch_relaylist(args: argparse.Namespace) -> int:
     for row in fetched["json"]:
         logger.debug("row[]='%s'", type(row))
         domain = urlparse(row["url"]).netloc.lower().split(":")[0]
-
         logger.debug("domain='%s' - AFTER!", domain)
+
         if domain is None and domain == "":
             logger.debug("domain='%s' is empty after tidyup.domain() - SKIPPED!", domain)
             continue
@@ -1776,6 +1779,7 @@ def fetch_relays(args: argparse.Namespace) -> int:
                         logger.debug("Appending domain='%s' to peers list for relay='%s' ...", domain, row["domain"])
                         peers.append(domain)
 
+                    logger.debug("domains()=%d,domain='%s'", len(domains), domain)
                     if dict_helper.has_key(domains, "domain", domain):
                         logger.debug("domain='%s' already added", domain)
                         continue
@@ -1817,6 +1821,7 @@ def fetch_relays(args: argparse.Namespace) -> int:
                     logger.debug("Appending domain='%s' to peers list for relay='%s' ...", domain, row["domain"])
                     peers.append(domain)
 
+                logger.debug("domains()=%d,domain='%s'", len(domains), domain)
                 if dict_helper.has_key(domains, "domain", domain):
                     logger.debug("domain='%s' already added", domain)
                     continue
@@ -1840,11 +1845,12 @@ def fetch_relays(args: argparse.Namespace) -> int:
                     logger.debug("Appending domain='%s' to peers list for relay='%s' ...", domain, row["domain"])
                     peers.append(domain)
 
+                logger.debug("domains()=%d,domain='%s'", len(domains), domain)
                 if dict_helper.has_key(domains, "domain", domain):
                     logger.debug("domain='%s' already added", domain)
                     continue
 
-                logger.debug("Appending domain='%s',origin='%s',software='%s'", domain, row["domain"], row["software"])
+                logger.debug("Appending domain='%s',origin='%s',software='%s' ...", domain, row["domain"], row["software"])
                 domains.append({
                     "domain": domain,
                     "origin": row["domain"],
index d70280781502b53d135ab69a22425df92837aa85..c79815c600dbcee2a234583d63777e05bb830fd9 100644 (file)
@@ -48,8 +48,8 @@ def instance(blocked: str, blocker: str, command: str) -> bool:
 
     logger.debug("blocked='%s' - BEFORE!", blocked)
     blocked = utils.deobfuscate(blocked, blocker)
+    logger.debug("blocked='%s' - AFTER!", blocked)
 
-    logger.debug("blocked='%s' - DEOBFUSCATED!", blocked)
     if instances.has_pending(blocker):
         logger.debug("Flushing updates for blocker='%s' ...", blocker)
         instances.update(blocker)
@@ -226,6 +226,7 @@ def csv_block(blocker: str, url: str, command: str):
                 "reason" : reason,
             })
 
+        logger.debug("reject_media='%s',reject_reports='%s'", reject_media, reject_reports)
         if reject_media:
             block(blocker, domain, None, "reject_media")
         if reject_reports:
index 6f7f033e029bbfe60c7a2eff94a40b454463bcbc..27fcad33d96ad100cd31c9ec559143ae865b6126 100644 (file)
@@ -227,8 +227,8 @@ def fetch_peers(domain: str, software: str, origin: str) -> list:
         data = network.get_json_api(
             domain,
             path,
-            headers,
-            (config.get("connection_timeout"), config.get("read_timeout"))
+            headers=headers,
+            timeout=(config.get("connection_timeout"), config.get("read_timeout"))
         )
 
         logger.debug("data[]='%s'", type(data))
@@ -268,8 +268,8 @@ def fetch_generator_from_path(domain: str, path: str = "/") -> str:
     response = network.fetch_response(
         domain,
         path,
-        network.web_headers,
-        (config.get("connection_timeout"), config.get("read_timeout")),
+        headers=network.web_headers,
+        timeout=(config.get("connection_timeout"), config.get("read_timeout")),
         allow_redirects=True
     )
 
@@ -568,8 +568,8 @@ def fetch_blocks(domain: str) -> list:
         data = network.get_json_api(
             domain,
             "/api/v1/instance/domain_blocks",
-            headers,
-            (config.get("connection_timeout"), config.get("read_timeout"))
+            headers=headers,
+            timeout=(config.get("connection_timeout"), config.get("read_timeout"))
         )
         rows = list()
 
index 6652c19261e7747d268f5213d3d220e207f1af14..8244a78a1cce162e056e235e8244ad3fcb3f5235 100644 (file)
@@ -62,9 +62,19 @@ def fetch_url(url: str, headers: dict, timeout: tuple) -> requests.models.Respon
     # Invoke other function, avoid trailing ?
     logger.debug("components[%s]='%s'", type(components), components)
     if components.query != "":
-        response = network.fetch_response(components.netloc.split(":")[0], f"{components.path}?{components.query}", headers, timeout)
+        response = network.fetch_response(
+            components.netloc.split(":")[0],
+            f"{components.path}?{components.query}",
+            headers,
+            timeout
+        )
     else:
-        response = network.fetch_response(components.netloc.split(":")[0], components.path if isinstance(components.path, str) and components.path != '' else '/', headers, timeout)
+        response = network.fetch_response(
+            components.netloc.split(":")[0],
+            components.path if isinstance(components.path, str) and components.path != '' else '/',
+            headers,
+            timeout
+        )
 
     logger.debug("response[]='%s' - EXIT!", type(response))
     return response