From 1d06145d9e92de8458e3fd6d0a7e75e629466f16 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 24 Jun 2023 14:01:29 +0200 Subject: [PATCH] Notation applied: - decimals in lazy strings with %d - strings with '%s' --- fba/commands.py | 4 ++-- fba/helpers/version.py | 6 +++--- fba/http/federation.py | 2 +- fba/http/network.py | 12 ++++++------ fba/networks/mastodon.py | 2 +- fba/networks/misskey.py | 18 +++++++++--------- fba/networks/pleroma.py | 2 +- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/fba/commands.py b/fba/commands.py index 2374f06..47a4c5a 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -68,7 +68,7 @@ def check_instance(args: argparse.Namespace) -> int: else: logger.info("args.domain='%s' is not known", args.domain) - logger.debug("status='%d' - EXIT!", status) + logger.debug("status=%d - EXIT!", status) return status def fetch_pixelfed_api(args: argparse.Namespace) -> int: @@ -334,7 +334,7 @@ def fetch_blocks(args: argparse.Namespace) -> int: logger.debug("Invoking blocks.add_instance(%s, %s, %s, %s)", blocker, block["blocked"], block["reason"], block['block_level']) blocks.add_instance(blocker, block["blocked"], block["reason"], block['block_level']) - logger.debug("block_level='%s',config[bot_enabled]=%s", block['block_level'], config.get("bot_enabled")) + logger.debug("block_level='%s',config[bot_enabled]='%s'", block['block_level'], config.get("bot_enabled")) if block['block_level'] == "reject" and config.get("bot_enabled"): logger.debug("blocker='%s' has blocked '%s' with reason='%s' - Adding to bot notification ...", blocker, block["blocked"], block["reason"]) blockdict.append({ diff --git a/fba/helpers/version.py b/fba/helpers/version.py index 96ba574..aa0c54f 100644 --- a/fba/helpers/version.py +++ b/fba/helpers/version.py @@ -96,7 +96,7 @@ def strip_powered_by(software: str) -> str: return software start = software.find("powered by ") - logger.debug("start[%s]='%d'", type(start), start) + logger.debug("start[%s]=%d", type(start), start) software = software[start + 11:].strip() logger.debug("software='%s'", software) @@ -117,7 +117,7 @@ def strip_hosted_on(software: str) -> str: return software end = software.find("hosted on ") - logger.debug("end[%s]='%d'", type(end), end) + logger.debug("end[%s]=%d", type(end), end) software = software[0:end].strip() logger.debug("software[%s]='%s'", type(software), software) @@ -144,7 +144,7 @@ def strip_until(software: str, until: str) -> str: # Next, strip until part end = software.find(until) - logger.debug("end[%s]='%d'", type(end), end) + logger.debug("end[%s]=%d", type(end), end) if end > 0: software = software[0:end].strip() diff --git a/fba/http/federation.py b/fba/http/federation.py index e3b93b1..84a0071 100644 --- a/fba/http/federation.py +++ b/fba/http/federation.py @@ -424,7 +424,7 @@ def determine_software(domain: str, path: str = None) -> str: # Continue raising it raise data["exception"] elif "error_message" in data: - logger.debug("Returned error_message during fetching nodeinfo: '%s',status_code='%d'", data['error_message'], data['status_code']) + logger.debug("Returned error_message during fetching nodeinfo: '%s',status_code=%d", data['error_message'], data['status_code']) return fetch_generator_from_path(domain) elif "status" in data and data["status"] == "error" and "message" in data: logger.warning("JSON response is an error: '%s'", data["message"]) diff --git a/fba/http/network.py b/fba/http/network.py index c57f0a5..d15b563 100644 --- a/fba/http/network.py +++ b/fba/http/network.py @@ -84,9 +84,9 @@ def post_json_api(domain: str, path: str, data: str = "", headers: dict = dict() json_reply["json"] = json_from_response(response) - logger.debug("response.ok='%s',response.status_code='%d',json_reply[]='%s'", response.ok, response.status_code, type(json_reply)) + logger.debug("response.ok='%s',response.status_code=%d,json_reply[]='%s'", response.ok, response.status_code, type(json_reply)) if not response.ok or response.status_code >= 400: - logger.warning("Cannot query JSON API: domain='%s',path='%s',data()=%d,response.status_code='%d',json_reply[]='%s'", domain, path, len(data), response.status_code, type(json_reply)) + logger.warning("Cannot query JSON API: domain='%s',path='%s',data()=%d,response.status_code=%d,json_reply[]='%s'", domain, path, len(data), response.status_code, type(json_reply)) json_reply["status_code"] = response.status_code json_reply["error_message"] = response.reason del json_reply["json"] @@ -124,7 +124,7 @@ def fetch_api_url(url: str, timeout: tuple) -> dict: logger.debug("response.ok='%s',response.status_code='%s',json_reply[]='%s'", response.ok, response.status_code, type(json_reply)) if not response.ok or response.status_code >= 400: - logger.warning("Cannot query JSON API: url='%s',response.status_code='%d',json_reply[]='%s'", url, response.status_code, type(json_reply)) + logger.warning("Cannot query JSON API: url='%s',response.status_code=%d,json_reply[]='%s'", url, response.status_code, type(json_reply)) json_reply["status_code"] = response.status_code json_reply["error_message"] = response.reason del json_reply["json"] @@ -175,9 +175,9 @@ def get_json_api(domain: str, path: str, headers: dict, timeout: tuple) -> dict: json_reply["json"] = json_from_response(response) - logger.debug("response.ok='%s',response.status_code='%d',json_reply[]='%s'", response.ok, response.status_code, type(json_reply)) + logger.debug("response.ok='%s',response.status_code=%d,json_reply[]='%s'", response.ok, response.status_code, type(json_reply)) if not response.ok or response.status_code >= 400: - logger.warning("Cannot query JSON API: domain='%s',path='%s',response.status_code='%d',json_reply[]='%s'", domain, path, response.status_code, type(json_reply)) + logger.warning("Cannot query JSON API: domain='%s',path='%s',response.status_code=%d,json_reply[]='%s'", domain, path, response.status_code, type(json_reply)) json_reply["status_code"] = response.status_code json_reply["error_message"] = response.reason del json_reply["json"] @@ -202,7 +202,7 @@ def send_bot_post(domain: str, blocklist: dict): logger.debug("blocklist()=%d", len(blocklist)) for block in blocklist: - logger.debug("block[%s]=%s", type(block), block) + logger.debug("block[%s]='%s'", type(block), block) if block["reason"] is None or block["reason"] == '': message = message + block["blocked"] + " with unspecified reason\n" else: diff --git a/fba/networks/mastodon.py b/fba/networks/mastodon.py index 78939bd..9ed961b 100644 --- a/fba/networks/mastodon.py +++ b/fba/networks/mastodon.py @@ -161,7 +161,7 @@ def fetch_blocks(domain: str, nodeinfo_url: str) -> list: logger.debug("data[]='%s'", type(data)) if "error_message" in data: - logger.debug("Was not able to fetch domain_blocks from domain='%s': status_code='%d',error_message='%s'", domain, data['status_code'], data['error_message']) + logger.debug("Was not able to fetch domain_blocks from domain='%s': status_code=%d,error_message='%s'", domain, data['status_code'], data['error_message']) instances.set_last_error(domain, data) return blocklist elif "json" in data and "error" in data["json"]: diff --git a/fba/networks/misskey.py b/fba/networks/misskey.py index fa169c7..e47c7dd 100644 --- a/fba/networks/misskey.py +++ b/fba/networks/misskey.py @@ -55,7 +55,7 @@ def fetch_peers(domain: str) -> list: # instances page-by-page, since that troonware doesn't support # sending them all at once while True: - logger.debug("Fetching offset='%d' from domain='%s' ...", offset, domain) + logger.debug("Fetching offset=%d from domain='%s' ...", offset, domain) if offset == 0: fetched = network.post_json_api(domain, "/api/federation/instances", json.dumps({ "sort" : "+pubAt", @@ -91,7 +91,7 @@ def fetch_peers(domain: str) -> list: logger.debug("Fetched %d row(s) but expected: %d", len(rows), config.get('misskey_limit')) offset = offset + (config.get("misskey_limit") - len(rows)) else: - logger.debug("Raising offset by step='%d'", step) + logger.debug("Raising offset by step=%d", step) offset = offset + step already = 0 @@ -147,9 +147,9 @@ def fetch_blocks(domain: str) -> list: # instances page-by-page since it doesn't support sending them all at once while True: try: - logger.debug("Fetching offset='%d' from domain='%s' ...", offset, domain) + logger.debug("Fetching offset=%d from domain='%s' ...", offset, domain) if offset == 0: - logger.debug("Sending JSON API request to domain='%s',step='%d',offset='%d'", domain, step, offset) + logger.debug("Sending JSON API request to domain='%s',step=%d,offset=%d", domain, step, offset) fetched = network.post_json_api(domain, "/api/federation/instances", json.dumps({ "sort" : "+pubAt", "host" : None, @@ -157,7 +157,7 @@ def fetch_blocks(domain: str) -> list: "limit" : step }), headers) else: - logger.debug("Sending JSON API request to domain='%s',step='%d',offset='%d'", domain, step, offset) + logger.debug("Sending JSON API request to domain='%s',step=%d,offset=%d", domain, step, offset) fetched = network.post_json_api(domain, "/api/federation/instances", json.dumps({ "sort" : "+pubAt", "host" : None, @@ -186,7 +186,7 @@ def fetch_blocks(domain: str) -> list: logger.debug("Fetched %d row(s) but expected: %d", len(rows), config.get('misskey_limit')) offset = offset + (config.get("misskey_limit") - len(rows)) else: - logger.debug("Raising offset by step='%d'", step) + logger.debug("Raising offset by step=%d", step) offset = offset + step count = 0 @@ -217,7 +217,7 @@ def fetch_blocks(domain: str) -> list: # Fetch blocked (full suspended) instances try: if offset == 0: - logger.debug("Sending JSON API request to domain='%s',step='%d',offset='%d'", domain, step, offset) + logger.debug("Sending JSON API request to domain='%s',step=%d,offset=%d", domain, step, offset) fetched = network.post_json_api(domain, "/api/federation/instances", json.dumps({ "sort" : "+pubAt", "host" : None, @@ -225,7 +225,7 @@ def fetch_blocks(domain: str) -> list: "limit" : step }), headers) else: - logger.debug("Sending JSON API request to domain='%s',step='%d',offset='%d'", domain, step, offset) + logger.debug("Sending JSON API request to domain='%s',step=%d,offset=%d", domain, step, offset) fetched = network.post_json_api(domain, "/api/federation/instances", json.dumps({ "sort" : "+pubAt", "host" : None, @@ -254,7 +254,7 @@ def fetch_blocks(domain: str) -> list: logger.debug("Fetched %d row(s) but expected: %d'", len(rows), config.get('misskey_limit')) offset = offset + (config.get("misskey_limit") - len(rows)) else: - logger.debug("Raising offset by step='%d'", step) + logger.debug("Raising offset by step=%d", step) offset = offset + step count = 0 diff --git a/fba/networks/pleroma.py b/fba/networks/pleroma.py index 9998321..8d0e6e0 100644 --- a/fba/networks/pleroma.py +++ b/fba/networks/pleroma.py @@ -329,7 +329,7 @@ def fetch_blocks_from_about(domain: str) -> dict: (config.get("connection_timeout"), config.get("read_timeout")) ) - logger.debug("response.ok='%s',response.status_code='%d',response.text()=%d", response.ok, response.status_code, len(response.text)) + 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.text.strip() == "": logger.warning("path='%s' does not exist on domain='%s' - SKIPPED!", path, domain) continue -- 2.39.5