print("WARNING: Did not update any rows:", domain)
except BaseException as e:
- print(f"ERROR: failed SQL query: domain='{domain}',exception:'{e}'")
+ print(f"ERROR: failed SQL query: domain='{domain}',exception:'{str(e)}'")
sys.exit(255)
# DEBUG: print("DEBUG: EXIT!")
print("WARNING: Did not update any rows:", domain)
except BaseException as e:
- print(f"ERROR: failed SQL query: domain='{domain}',sql='{sql}',exception:'{e}'")
+ print(f"ERROR: failed SQL query: domain='{domain}',sql='{sql}',exception:'{str(e)}'")
sys.exit(255)
# DEBUG: print("DEBUG: Deleting nodeinfos for domain:", domain)
pending_errors[domain] = res
except BaseException as e:
- print(f"ERROR: failed SQL query: domain='{domain}',exception:'{e}'")
+ print(f"ERROR: failed SQL query: domain='{domain}',exception:'{str(e)}'")
sys.exit(255)
# DEBUG: print("DEBUG: EXIT!")
print("WARNING: Did not update any rows:", domain)
except BaseException as e:
- print(f"ERROR: failed SQL query: domain='{domain}',exception:'{e}'")
+ print(f"ERROR: failed SQL query: domain='{domain}',exception:'{str(e)}'")
sys.exit(255)
connection.commit()
# DEBUG: print("DEBUG: Returned zero bytes, exiting loop:", domain)
break
elif len(fetched) != config["misskey_offset"]:
- print(f"WARNING: Fetched '{len(fetched)}' row(s) but expected: '{config['misskey_offset']}'")
+ # DEBUG: print(f"DEBUG: Fetched '{len(fetched)}' row(s) but expected: '{config['misskey_offset']}'")
offset = offset + (config["misskey_offset"] - len(fetched))
else:
# DEBUG: print("DEBUG: Raising offset by step:", step)
try:
res = reqto.get(f"https://{domain}/api/v3/site", headers=api_headers, timeout=(config["connection_timeout"], config["read_timeout"]))
- # DEBUG: print(f"DEBUG: res.ok={res.ok},res.status_code='{res.status_code}'")
+ # DEBUG: print(f"DEBUG: res.ok={res.ok},res.status_code='{res.status_code}',res.json[]='{type(res.json())}'")
if not res.ok or res.status_code >= 400:
print("WARNING: Could not reach any JSON API:", domain)
update_last_error(domain, res)
+ elif res.ok and isinstance(res.json(), list):
+ # DEBUG: print(f"DEBUG: domain='{domain}' returned a list: '{res.json()}'")
+ sys.exit(255)
elif "federated_instances" in res.json():
# DEBUG: print("DEBUG: Found federated_instances", domain)
peers = peers + add_peers(res.json()["federated_instances"])
update_last_error(domain, res)
except BaseException as e:
- print(f"WARNING: Exception during fetching JSON: domain='{domain}',exception:'{e}'")
+ print(f"WARNING: Exception during fetching JSON: domain='{domain}',exception:'{str(e)}'")
update_last_nodeinfo(domain)
try:
res = reqto.get(f"https://{domain}/api/v1/server/{mode}?start={start}&count=100", headers=api_headers, timeout=(config["connection_timeout"], config["read_timeout"]))
- # DEBUG: print(f"DEBUG: res.ok={res.ok},res.status_code='{res.status_code}'")
+ # DEBUG: print(f"DEBUG: res.ok={res.ok},res.status_code='{res.status_code}',res.json[]='{type(res.json())}'")
if res.ok and isinstance(res.json(), dict):
# DEBUG: print("DEBUG: Success, res.json():", len(res.json()))
data = res.json()
start = start + 100
except BaseException as e:
- print(f"WARNING: Exception during fetching JSON: domain='{domain}',exception:'{e}'")
+ print(f"WARNING: Exception during fetching JSON: domain='{domain}',exception:'{str(e)}'")
update_last_nodeinfo(domain)
try:
res = reqto.get(f"https://{domain}{get_peers_url}", headers=api_headers, timeout=(config["connection_timeout"], config["read_timeout"]))
- # DEBUG: print(f"DEBUG: res.ok={res.ok},res.status_code={res.status_code}")
+ # DEBUG: print(f"DEBUG: res.ok={res.ok},res.status_code={res.status_code},res.json[]='{type(res.json())}'")
if not res.ok or res.status_code >= 400:
# DEBUG: print(f"DEBUG: Was not able to fetch '{get_peers_url}', trying alternative ...")
res = reqto.get(f"https://{domain}/api/v3/site", headers=api_headers, timeout=(config["connection_timeout"], config["read_timeout"]))
+ # DEBUG: print(f"DEBUG: res.ok={res.ok},res.status_code={res.status_code},res.json[]='{type(res.json())}'")
if not res.ok or res.status_code >= 400:
print("WARNING: Could not reach any JSON API:", domain)
update_last_error(domain, res)
+ elif res.ok and isinstance(res.json(), list):
+ # DEBUG: print(f"DEBUG: domain='{domain}' returned a list: '{res.json()}'")
+ sys.exit(255)
elif "federated_instances" in res.json():
# DEBUG: print("DEBUG: Found federated_instances", domain)
peers = peers + add_peers(res.json()["federated_instances"])
def post_json_api(domain: str, path: str, parameter: str, extra_headers: dict = {}) -> list:
# DEBUG: print("DEBUG: Sending POST to domain,path,parameter:", domain, path, parameter, extra_headers)
- data = {}
+ data = list()
try:
res = reqto.post(f"https://{domain}{path}", data=parameter, headers={**api_headers, **extra_headers}, timeout=(config["connection_timeout"], config["read_timeout"]))
- # DEBUG: print(f"DEBUG: res.ok={res.ok},res.status_code={res.status_code}")
+ # DEBUG: print(f"DEBUG: res.ok={res.ok},res.status_code={res.status_code},res.json[]='{type(res.json())}'")
if not res.ok or res.status_code >= 400:
- print(f"WARNING: Cannot query JSON API: domain='{domain}',path='{path}',parameter()={len(parameter)},res.status_code='{res.status_code}'")
+ print(f"WARNING: Cannot query JSON API: domain='{domain}',path='{path}',parameter()={len(parameter)},res.status_code='{res.status_code}',res.json[]='{type(res.json())}'")
update_last_error(domain, res)
else:
update_last_nodeinfo(domain)
data = res.json()
except BaseException as e:
- print(f"WARNING: Some error during post(): domain='{domain},path='{path}',parameter()={len(parameter)},exception:'{e}'")
+ print(f"WARNING: Some error during post(): domain='{domain}',path='{path}',parameter()={len(parameter)},exception:'{str(e)}'")
# DEBUG: print("DEBUG: Returning data():", len(data))
return data
# DEBUG: print("DEBUG: Fetching request:", request)
res = reqto.get(request, headers=api_headers, timeout=(config["connection_timeout"], config["read_timeout"]))
- # DEBUG: print(f"DEBUG: res.ok={res.ok},res.status_code={res.status_code}")
+ # DEBUG: print(f"DEBUG: res.ok={res.ok},res.status_code={res.status_code},res.json[]='{type(res.json())}'")
if res.ok and isinstance(res.json(), dict):
# DEBUG: print("DEBUG: Success:", request)
data = res.json()
nodeinfos["detection_mode"][domain] = "STATIC_CHECK"
nodeinfos["nodeinfo_url"][domain] = request
break
+ elif res.ok and isinstance(res.json(), list):
+ # DEBUG: print(f"DEBUG: domain='{domain}' returned a list: '{res.json()}'")
+ sys.exit(255)
elif not res.ok or res.status_code >= 400:
print("WARNING: Failed fetching nodeinfo from domain:", domain)
update_last_error(domain, res)
print("WARNING: Did not update any rows:", domain)
except BaseException as e:
- print(f"ERROR: failed SQL query: reason='{reason}',blocker='{blocker}',blocked='{blocked}',block_level='{block_level}',sql='{sql}',exception:'{e}'")
+ print(f"ERROR: failed SQL query: reason='{reason}',blocker='{blocker}',blocked='{blocked}',block_level='{block_level}',sql='{sql}',exception:'{str(e)}'")
sys.exit(255)
# DEBUG: print("DEBUG: EXIT!")
print("WARNING: Did not update any rows:", domain)
except BaseException as e:
- print(f"ERROR: failed SQL query: last_seen='{last_seen}',blocker='{blocker}',blocked='{blocked}',block_level='{block_level}',exception:'{e}'")
+ print(f"ERROR: failed SQL query: last_seen='{last_seen}',blocker='{blocker}',blocked='{blocked}',block_level='{block_level}',exception:'{str(e)}'")
sys.exit(255)
# DEBUG: print("DEBUG: EXIT!")
)
except BaseException as e:
- print(f"ERROR: failed SQL query: blocker='{blocker}',blocked='{blocked}',reason='{reason}',block_level='{block_level}',first_seen='{first_seen}',last_seen='{last_seen}',exception:'{e}'")
+ print(f"ERROR: failed SQL query: blocker='{blocker}',blocked='{blocked}',reason='{reason}',block_level='{block_level}',first_seen='{first_seen}',last_seen='{last_seen}',exception:'{str(e)}'")
sys.exit(255)
# DEBUG: print("DEBUG: EXIT!")
# Check condition
registered = cursor.fetchone() != None
except BaseException as e:
- print(f"ERROR: failed SQL query: last_seen='{last_seen}'blocker='{blocker}',blocked='{blocked}',block_level='{block_level}',first_seen='{first_seen}',last_seen='{last_seen}',exception:'{e}'")
+ print(f"ERROR: failed SQL query: last_seen='{last_seen}'blocker='{blocker}',blocked='{blocked}',block_level='{block_level}',first_seen='{first_seen}',last_seen='{last_seen}',exception:'{str(e)}'")
sys.exit(255)
# DEBUG: print(f"DEBUG: registered='{registered}' - EXIT!")
remove_pending_error(domain)
except BaseException as e:
- print(f"ERROR: failed SQL query: domain='{domain}',exception:'{e}'")
+ print(f"ERROR: failed SQL query: domain='{domain}',exception:'{str(e)}'")
sys.exit(255)
else:
# DEBUG: print("DEBUG: Updating nodeinfo for domain:", domain)
# instances page-by-page, since that troonware doesn't support
# sending them all at once
try:
- print(f"DEBUG: Fetching offset='{offset}' from '{domain}' ...")
+ # DEBUG: print(f"DEBUG: Fetching offset='{offset}' from '{domain}' ...")
if offset == 0:
# DEBUG: print("DEBUG: Sending JSON API request to domain,step,offset:", domain, step, offset)
fetched = post_json_api(domain, "/api/federation/instances", json.dumps({
"offset" : offset - 1
}), {"Origin": domain})
- print("DEBUG: fetched():", len(fetched))
+ # DEBUG: print("DEBUG: fetched():", len(fetched))
if len(fetched) == 0:
# DEBUG: print("DEBUG: Returned zero bytes, exiting loop:", domain)
break
elif len(fetched) != config["misskey_offset"]:
- print(f"WARNING: Fetched '{len(fetched)}' row(s) but expected: '{config['misskey_offset']}'")
+ # DEBUG: print(f"DEBUG: Fetched '{len(fetched)}' row(s) but expected: '{config['misskey_offset']}'")
offset = offset + (config["misskey_offset"] - len(fetched))
else:
# DEBUG: print("DEBUG: Raising offset by step:", step)
"offset" : offset-1
}), {"Origin": domain})
- print("DEBUG: fetched():", len(fetched))
+ # DEBUG: print("DEBUG: fetched():", len(fetched))
if len(fetched) == 0:
# DEBUG: print("DEBUG: Returned zero bytes, exiting loop:", domain)
break
elif len(fetched) != config["misskey_offset"]:
- print(f"WARNING: Fetched '{len(fetched)}' row(s) but expected: '{config['misskey_offset']}'")
+ # DEBUG: print(f"DEBUG: Fetched '{len(fetched)}' row(s) but expected: '{config['misskey_offset']}'")
offset = offset + (config["misskey_offset"] - len(fetched))
else:
# DEBUG: print("DEBUG: Raising offset by step:", step)