def fetch_peers(domain: str) -> list:
# DEBUG: print(f"DEBUG: domain({len(domain)})={domain} - CALLED!")
- if type(domain) != str:
+ if not isinstance(domain, str):
raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
elif domain == "":
- raise ValueError(f"Parameter 'domain' is empty")
+ raise ValueError("Parameter 'domain' is empty")
# DEBUG: print(f"DEBUG: domain='{domain}' is misskey, sending API POST request ...")
peers = list()
if not "host" in row:
print(f"WARNING: row()={len(row)} does not contain key 'host': {row},domain='{domain}'")
continue
- elif type(row["host"]) != str:
+ elif not isinstance(row["host"], str):
print(f"WARNING: row[host][]={type(row['host'])} is not 'str'")
continue
elif blacklist.is_blacklisted(row["host"]):
break
# DEBUG: print(f"DEBUG: Adding '{len(peers)}' for domain='{domain}'")
- instances.set("total_peers", domain, len(peers))
+ 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)
def fetch_blocks(domain: str) -> dict:
# DEBUG: print(f"DEBUG: domain='{domain}' - CALLED!")
- if type(domain) != str:
+ if not isinstance(domain, str):
raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
elif domain == "":
- raise ValueError(f"Parameter 'domain' is empty")
+ raise ValueError("Parameter 'domain' is empty")
# DEBUG: print("DEBUG: Fetching misskey blocks from domain:", domain)
blocklist = {
# DEBUG: print(f"DEBUG: count={count}")
if count == 0:
- # DEBUG: print(f"DEBUG: API is no more returning new instances, aborting loop!")
+ # DEBUG: print("DEBUG: API is no more returning new instances, aborting loop!")
break
- except BaseException as e:
- print("WARNING: Caught error, exiting loop:", domain, e)
- instances.update_last_error(domain, e)
+ except BaseException as exc:
+ print("WARNING: Caught error, exiting loop:", domain, exc)
+ instances.update_last_error(domain, exc)
offset = 0
break
# DEBUG: print(f"DEBUG: count={count}")
if count == 0:
- # DEBUG: print(f"DEBUG: API is no more returning new instances, aborting loop!")
+ # DEBUG: print("DEBUG: API is no more returning new instances, aborting loop!")
break
- except BaseException as e:
- print("ERROR: Exception during POST:", domain, e)
- instances.update_last_error(domain, e)
+ except BaseException as exc:
+ print("ERROR: Exception during POST:", domain, exc)
+ instances.update_last_error(domain, exc)
offset = 0
break