From: Enju Aihara <5-EnjuAihara@users.noreply.gitlab.varis.social> Date: Sat, 5 Mar 2022 08:41:11 +0000 (+0100) Subject: only clear blocks if theres no error X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=bea677e5859f1409ae0be35aae338a8037740ec4;p=fba.git only clear blocks if theres no error --- diff --git a/fetch_blocks.py b/fetch_blocks.py index 1f4409a..6c7491b 100644 --- a/fetch_blocks.py +++ b/fetch_blocks.py @@ -8,9 +8,8 @@ c = conn.cursor() with open("pleroma_instances.txt", "r") as f: while blocker := f.readline().strip(): print(blocker) - c.execute("delete from blocks where blocker = ?", (blocker,)) - conn.commit() try: + c.execute("delete from blocks where blocker = ?", (blocker,)) json = loads(get(f"https://{blocker}/nodeinfo/2.1.json").text) for mrf in json["metadata"]["federation"]["mrf_simple"]: for blocked in json["metadata"]["federation"]["mrf_simple"][mrf]: @@ -30,9 +29,8 @@ with open("pleroma_instances.txt", "r") as f: with open("mastodon_instances.txt", "r") as f: while blocker := f.readline().strip(): print(blocker) - c.execute("delete from blocks where blocker = ?", (blocker,)) - conn.commit() try: + c.execute("delete from blocks where blocker = ?", (blocker,)) json = loads(get(f"http://127.0.0.1:8069/{blocker}").text) for blocked in json["reject"]: if blocked["domain"].count("*") > 1: