continue
# DEBUG: print(f"DEBUG: blocker='{blocker}'")
- instances.update_last_blocked(blocker)
+ instances.set_data("last_blocked", blocker, time.time())
if software == "pleroma":
print(f"INFO: blocker='{blocker}',software='{software}'")
else:
print("WARNING: Unknown software:", blocker, software)
+ if instances.has_pending(blocker):
+ # DEBUG: print(f"DEBUG: Invoking instances.update_data({blocker}) ...")
+ instances.update_data(blocker)
+
if config.get("bot_enabled") and len(blockdict) > 0:
network.send_bot_post(blocker, blockdict)
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import bs4
+import time
import validators
from fba import blacklist
raise ValueError(f"Parameter origin[]='{type(origin)}' is not 'str'")
elif software is None:
# DEBUG: print(f"DEBUG: Updating last_instance_fetch for domain='{domain}' ...")
- instances.update_last_instance_fetch(domain)
+ instances.set_data("last_instance_fetch", domain, time.time())
# DEBUG: print(f"DEBUG: software for domain='{domain}' is not set, determining ...")
software = determine_software(domain, path)
# DEBUG: print("DEBUG: Adding new domain:", domain, origin)
instances.add(domain, origin, command, path)
+ # DEBUG: print(f"DEBUG: Updating last_instance_fetch for domain='{domain}' ...")
+ instances.set_data("last_instance_fetch", domain, time.time())
+
# DEBUG: print("DEBUG: Fetching instances for domain:", domain, software)
peerlist = fetch_peers(domain, software)
# DEBUG: print(f"DEBUG: Adding '{len(peers)}' for domain='{domain}'")
instances.set_data("total_peers", domain, len(peers))
- # DEBUG: print(f"DEBUG: Updating last_instance_fetch for domain='{domain}' ...")
- instances.update_last_instance_fetch(domain)
-
# DEBUG: print("DEBUG: Returning peers[]:", type(peers))
return peers
# DEBUG: print("DEBUG: EXIT!")
-def update_last_instance_fetch(domain: str):
- # DEBUG: print(f"DEBUG: domain='{domain}' - CALLED!")
- if not isinstance(domain, str):
- raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'")
- elif domain == "":
- raise ValueError("Parameter 'domain' is empty")
-
- # DEBUG: print("DEBUG: Updating last_instance_fetch for domain:", domain)
- set_data("last_instance_fetch", domain, time.time())
-
- # Running pending updated
- # DEBUG: print(f"DEBUG: Invoking update_data({domain}) ...")
- update_data(domain)
-
- # DEBUG: print("DEBUG: EXIT!")
-
-def update_last_blocked(domain: str):
- # DEBUG: print(f"DEBUG: domain='{domain}' - CALLED!")
- if not isinstance(domain, str):
- raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'")
- elif domain == "":
- raise ValueError("Parameter 'domain' is empty")
-
- # DEBUG: print("DEBUG: Updating last_blocked for domain", domain)
- set_data("last_blocked", domain, time.time())
-
- # Running pending updated
- # DEBUG: print(f"DEBUG: Invoking update_data({domain}) ...")
- update_data(domain)
-
- # DEBUG: print("DEBUG: EXIT!")
-
def add(domain: str, origin: str, command: str, path: str = None):
# DEBUG: print(f"DEBUG: domain='{domain}',origin='{origin}',command='{command}',path='{path}' - CALLED!")
if not isinstance(domain, str):
except network.exceptions as exception:
print(f"WARNING: Exception '{type(exception)}' during fetching instances (friendica) from domain='{domain}'")
instances.update_last_error(domain, exception)
-
- if instances.has_pending(domain):
- instances.update_data(domain)
-
return dict()
# Prevents exceptions:
# DEBUG: print(f"DEBUG: Adding '{len(peers)}' for domain='{domain}'")
instances.set_data("total_peers", domain, len(peers))
- # DEBUG: print(f"DEBUG: Updating last_instance_fetch for domain='{domain}' ...")
- instances.update_last_instance_fetch(domain)
-
# DEBUG: print("DEBUG: Returning peers[]:", type(peers))
return peers
# DEBUG: print(f"DEBUG: Adding '{len(peers)}' for domain='{domain}'")
instances.set_data("total_peers", domain, len(peers))
- # DEBUG: print(f"DEBUG: Updating last_instance_fetch for domain='{domain}' ...")
- instances.update_last_instance_fetch(domain)
-
# DEBUG: print(f"DEBUG: Returning peers[]='{type(peers)}'")
return peers
offset = 0
break
- # DEBUG: print(f"DEBUG: Updating last_instance_fetch for domain='{domain}' ...")
- instances.update_last_instance_fetch(domain)
-
# DEBUG: print(f"DEBUG: Returning for domain='{domain}',blocked()={len(blocklist['blocked'])},suspended()={len(blocklist['suspended'])}")
return {
"reject" : blocklist["blocked"],
print(f"DEBUG: data['{type(data)}']='{data}'")
if "error_message" not in data:
- print("DEBUG: Success, data[json]:", len(data["json"]))
+ print(f"DEBUG: Success, data[json]()={len(data['json'])}")
if "data" in data["json"]:
rows = data["json"]["data"]
print(f"DEBUG: Adding '{len(peers)}' for domain='{domain}'")
instances.set_data("total_peers", domain, len(peers))
- print(f"DEBUG: Updating last_instance_fetch for domain='{domain}' ...")
- instances.update_last_instance_fetch(domain)
-
print(f"DEBUG: Returning peers[]='{type(peers)}'")
return peers