logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
-def from_response(response: requests.models.Response) -> list:
+def from_response(response: requests.models.Response) -> any:
logger.debug("response[]='%s' - CALLED!", type(response))
if not isinstance(response, requests.models.Response):
raise ValueError(f"Parameter response[]='{type(response)}' is not type of 'Response'")
logger.debug("data[]='%s' - EXIT!", type(data))
if not isinstance(data, list) and not isinstance(data, dict):
- logger.debug("data[]='%s' is not wanted, wrapping into 'dict'", type(data))
+ logger.warning("data[]='%s' is not wanted, wrapping into 'dict'", type(data))
data = {data}
except json.decoder.JSONDecodeError as exception:
logger.debug("data[]='%s'", type(data))
if "exception" in data:
# Continue raising it
+ logger.debug("data()=%d contains exception='%s' - raising ...", len(data), type(data["exception"]))
raise data["exception"]
elif "error_message" in data:
logger.debug("Returned error_message during fetching nodeinfo: '%s',status_code=%d", data['error_message'], data['status_code'])
logger.warning("JSON response contains only a message: '%s'", data["message"])
instances.set_last_error(domain, data["message"])
return fetch_generator_from_path(domain)
- elif "software" not in data or "name" not in data["software"]:
+ elif "json" not in data or "software" not in data["json"] or "name" not in data["json"]["software"]:
logger.debug("JSON response from domain='%s' does not include [software][name], fetching / ...", domain)
software = fetch_generator_from_path(domain)
logger.debug("Generator for domain='%s' is: '%s'", domain, software)
- elif "software" in data and "name" in data["software"]:
- logger.debug("Found data[software][name] in JSON response")
- software = data["software"]["name"]
+ elif "json" in data and "software" in data["json"] and "name" in data["json"]["software"]:
+ logger.debug("Found data[json][software][name] in JSON response")
+ software = data["json"]["software"]["name"]
+ logger.debug("software[%s]='%s'", type(software), software)
if software is None:
logger.debug("Returning None - EXIT!")
return None