From: Roland Häder Date: Mon, 22 May 2023 00:11:50 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=85ec58708635b6c505d5e5ed7c203d674fa8444d;p=fba.git Continued: - try to strip of path if not aliased and known - fixed some errors --- diff --git a/fba.py b/fba.py index 5c13864..5a5281c 100644 --- a/fba.py +++ b/fba.py @@ -166,23 +166,28 @@ def determine_software(domain: str) -> str: try: json = fetch_nodeinfo(domain) + # NOISY-DEBUG: print("DEBUG: json():", len(json)) + software = tidyup(json["software"]["name"]) - if json["software"]["name"] in ["akkoma", "rebased"]: - # NOISY-DEBUG: print("DEBUG: Setting pleroma:", domain, json["software"]["name"]) + # NOISY-DEBUG: print("DEBUG: BEFORE software:", software) + if software in ["akkoma", "rebased"]: + # NOISY-DEBUG: print("DEBUG: Setting pleroma:", domain, software) software = "pleroma" - elif json["software"]["name"] in ["hometown", "ecko"]: - # NOISY-DEBUG: print("DEBUG: Setting mastodon:", domain, json["software"]["name"]) + elif software in ["hometown", "ecko"]: + # NOISY-DEBUG: print("DEBUG: Setting mastodon:", domain, software) software = "mastodon" - elif json["software"]["name"] in ["calckey", "groundpolis", "foundkey", "cherrypick"]: - # NOISY-DEBUG: print("DEBUG: Setting misskey:", domain, json["software"]["name"]) + elif software in ["calckey", "groundpolis", "foundkey", "cherrypick"]: + # NOISY-DEBUG: print("DEBUG: Setting misskey:", domain, software) software = "misskey" - else: - # NOISY-DEBUG: print("DEBUG: Using name:", domain, json["software"]["name"]) - software = tidyup(json["software"]["name"].lower()) - - if software == "": - software = None + elif software.find("/") > 0: + print("WARNING: Spliting of path:", software) + software = software.split("/")[-1]; + + if software == "": + print("WARNING: tidyup() left no software name behind:", domain) + software = None + # NOISY-DEBUG: print("DEBUG: AFTER software:", software) except: print("WARNING: Could not determine software type:", domain) diff --git a/fetch_blocks.py b/fetch_blocks.py index 247d15d..57a53a8 100644 --- a/fetch_blocks.py +++ b/fetch_blocks.py @@ -10,10 +10,10 @@ fba.cursor.execute( ) for blocker, software in fba.cursor.fetchall(): - # NOISY-DEBUG: print("DEBUG: BEFORE-blocker,software:", blocker, software) + # NOISY-DEBUG: print("DEBUG: BEFORE blocker,software:", blocker, software) blockdict = [] blocker = fba.tidyup(blocker) - # NOISY-DEBUG: print("DEBUG: AFTER-blocker,software:", blocker, software) + # NOISY-DEBUG: print("DEBUG: AFTER blocker,software:", blocker, software) if blocker == "": print("WARNING: blocker is now empty!") @@ -165,7 +165,7 @@ for blocker, software in fba.cursor.fetchall(): # handling CSRF, I've saw at least one server requiring it to access the endpoint # NOISY-DEBUG: print("DEBUG: Fetching meta:", blocker) meta = bs4.BeautifulSoup( - reqto.get(f"https://{blocker}/about", headers=fba.headers, timeout=fba.(config["connection_timeout"], config["read_timeout"])).text, + reqto.get(f"https://{blocker}/about", headers=fba.headers, timeout=(fba.config["connection_timeout"], config["read_timeout"])).text, "html.parser", ) try: @@ -177,7 +177,7 @@ for blocker, software in fba.cursor.fetchall(): reqheaders = fba.headers # NOISY-DEBUG: print("DEBUG: Quering API domain_blocks:", blocker) - blocks = reqto.get(f"https://{blocker}/api/v1/instance/domain_blocks", headers=reqheaders, timeout=fba.(config["connection_timeout"], config["read_timeout"])).json() + blocks = reqto.get(f"https://{blocker}/api/v1/instance/domain_blocks", headers=reqheaders, timeout=(fba.config["connection_timeout"], config["read_timeout"])).json() # NOISY-DEBUG: print("DEBUG: blocks():", len(blocks)) for block in blocks: @@ -286,9 +286,9 @@ for blocker, software in fba.cursor.fetchall(): for instance in blocks: blocked, reason = instance.values() - # NOISY-DEBUG: print("DEBUG: BEFORE-blocked:", blocked) + # NOISY-DEBUG: print("DEBUG: BEFORE blocked:", blocked) blocked = fba.tidyup(blocked) - # NOISY-DEBUG: print("DEBUG: AFTER-blocked:", blocked) + # NOISY-DEBUG: print("DEBUG: AFTER blocked:", blocked) if blocked == "": print("WARNING: blocked is empty:", blocker) @@ -347,7 +347,7 @@ for blocker, software in fba.cursor.fetchall(): print("INFO: blocker:", blocker) try: # Blocks - federation = reqto.get(f"https://{blocker}/api/v1/instance/peers?filter=suspended", headers=fba.headers, timeout=fba.(config["connection_timeout"], config["read_timeout"])).json() + federation = reqto.get(f"https://{blocker}/api/v1/instance/peers?filter=suspended", headers=fba.headers, timeout=(fba.config["connection_timeout"], config["read_timeout"])).json() if (federation == None): print("WARNING: No valid response:", blocker); @@ -357,9 +357,9 @@ for blocker, software in fba.cursor.fetchall(): # NOISY-DEBUG: print("DEBUG: Checking fenderation():", len(federation)) for peer in federation: blocked = peer["domain"].lower() - # NOISY-DEBUG: print("DEBUG: BEFORE-blocked:", blocked) + # NOISY-DEBUG: print("DEBUG: BEFORE blocked:", blocked) blocked = fba.tidyup(blocked) - # NOISY-DEBUG: print("DEBUG: AFTER-blocked:", blocked) + # NOISY-DEBUG: print("DEBUG: AFTER blocked:", blocked) if blocked == "": print("WARNING: blocked is empty:", blocker)