Add better timeout to the blocklist script

pull/56/head
db0 2023-10-24 14:02:26 +02:00
parent 92b9ce3b8b
commit aca3d807ba
2 changed files with 9 additions and 6 deletions

View File

@ -1,4 +1,4 @@
requests requests
pythorhead pythorhead
pythonseer>=0.1.3 pythonseer>=0.16.0
python-dotenv python-dotenv

View File

@ -47,7 +47,7 @@ min_censures = 1
changes_warning_threshold = 10 changes_warning_threshold = 10
password = os.getenv("LEMMY_PASSWORD", PASSWORD) password = os.getenv("LEMMY_PASSWORD", PASSWORD)
lemmy = Lemmy(f"https://{LEMMY_DOMAIN}") lemmy = Lemmy(f"https://{LEMMY_DOMAIN}", request_timeout=15)
if lemmy.log_in(USERNAME, password) is False: if lemmy.log_in(USERNAME, password) is False:
raise Exception("Could not log in to lemmy") raise Exception("Could not log in to lemmy")
@ -116,7 +116,10 @@ else:
ret = lemmy.site.edit( ret = lemmy.site.edit(
blocked_instances=list(defed), blocked_instances=list(defed),
) )
print("Edit Successful") if ret is None:
with open("previous_defed.json", 'w') as file: print("Edit Failed!")
file.write(json.dumps(list(defed),indent=4)) else:
print("Stored previous defed list to disk file 'previous_defed.json'") print("Edit Successful.")
with open("previous_defed.json", 'w') as file:
file.write(json.dumps(list(defed),indent=4))
print("Stored previous defed list to disk file 'previous_defed.json'")