allow_redirects=False
)
- logger.debug("Parsing JSON response from domain='%s',path='%s' ...", domain, path)
- json_reply["json"] = json_helper.from_response(response)
+ logger.debug("response.ok='%s',response.status_code=%d,response.reason='%s'", response.ok, response.status_code, response.reason)
+ if response.ok and response.status_code == 200:
+ logger.debug("Parsing JSON response from domain='%s',path='%s' ...", domain, path)
+ json_reply["json"] = json_helper.from_response(response)
logger.debug("response.ok='%s',response.status_code=%d,response.text()=%d", response.ok, response.status_code, len(response.text))
if not response.ok or response.status_code >= 300 or len(response.text.strip()) == 0:
json_reply["status_code"] = response.status_code
json_reply["error_message"] = response.reason
instances.set_last_error(domain, response)
- del json_reply["json"]
except exceptions as exception:
logger.debug("Fetching path='%s' from domain='%s' failed. exception[%s]='%s'", path, domain, type(exception), str(exception))
logger.debug("Fetching url='%s' ...", url)
response = utils.fetch_url(url, api_headers, timeout)
- logger.debug("Parsing JSON response from url='%s' ...", url)
- json_reply["json"] = json_helper.from_response(response)
+ logger.debug("response.ok='%s',response.status_code=%d,response.reason='%s'", response.ok, response.status_code, response.reason)
+ if response.ok and response.status_code == 200:
+ logger.debug("Parsing JSON response from url='%s' ...", url)
+ json_reply["json"] = json_helper.from_response(response)
logger.debug("response.ok='%s',response.status_code='%s',response.text()=%d", response.ok, response.status_code, len(response.text))
if not response.ok or response.status_code >= 300 or len(response.text) == 0:
logger.warning("Cannot query JSON API: url='%s',response.status_code=%d,response.text()=%d", url, response.status_code, len(response.text))
json_reply["status_code"] = response.status_code
json_reply["error_message"] = response.reason
- del json_reply["json"]
except exceptions as exception:
logger.debug("Fetching url='%s' failed. exception[%s]='%s'", url, type(exception), str(exception))
instances.set_last_error(domain, exception)
raise exception
- logger.debug("Parsing JSON response from domain='%s',path='%s' ...", domain, path)
- json_reply["json"] = json_helper.from_response(response)
+ logger.debug("response.ok='%s',response.status_code=%d,response.reason='%s'", response.ok, response.status_code, response.reason)
+ if response.ok and response.status_code == 200:
+ logger.debug("Parsing JSON response from domain='%s',path='%s' ...", domain, path)
+ json_reply["json"] = json_helper.from_response(response)
logger.debug("response.ok='%s',response.status_code=%d,response.text()=%d", response.ok, response.status_code, len(response.text))
if not response.ok or response.status_code >= 300 or len(response.text) == 0:
json_reply["status_code"] = response.status_code
json_reply["error_message"] = response.reason
instances.set_last_error(domain, response)
- del json_reply["json"]
logger.debug("Returning json_reply(%d)[]='%s' - EXIT!", len(json_reply), type(json_reply))
return json_reply