logger = logging.getLogger(__name__)
def raise_on(domain: str):
- logger.debug("domain='%s' - CALLED!")
+ logger.debug("domain='%s' - CALLED!", domain)
if not isinstance(domain, str):
raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'")
elif domain == "":
instances.set_last_error(domain, exception)
return list()
- paths = {
+ paths = [
"/api/v1/instance/peers",
"/api/v3/site",
- }
+ ]
# Init peers variable
peers = list()
logger.debug("Was not able to fetch peers from path='%s',domain='%s' ...", path, domain)
instances.set_last_error(domain, data)
elif "json" in data and len(data["json"]) > 0:
- logger.debug("Querying API path='%s' was successful: domain='%s',data[json]()=%d", path, domain, len(data['json']))
+ logger.debug("Querying API path='%s' was successful: domain='%s',data[json][%s]()=%d", path, domain, type(data['json']), len(data['json']))
peers = data["json"]
instances.set_success(domain)
break
+ if not isinstance(peers, list):
+ logger.warning("peers[]='%s' is not 'list', maybe bad API response?", type(peers))
+ peers = list()
+
logger.debug("Invoking instances.set_total_peers(%s,%d) ...", domain, len(peers))
instances.set_total_peers(domain, peers)
"/nodeinfo/2.0.json",
"/nodeinfo/2.0",
"/nodeinfo/1.0",
- "/api/v1/instance"
+ "/api/v1/instance",
]
for request in request_paths:
domain_helper.raise_on(domain)
if not isinstance(peers, list):
- raise ValueError(f"Parameter peers[]='{type(peers)}' is not 'list'")
+ raise ValueError(f"Parameter peers[]='{type(peers)}' is not 'list': '%s'")
# Set timestamp
_set_data("total_peers", domain, len(peers))