def http_request(self, call, url, **kwargs):
try:
# Remove args with no value
kwargs = self.unused(kwargs)
if self.client.timeout:
kwargs['timeout'] = self.client.timeout
if self.debug:
print("-- %s on %s with %s " % (call.__name__.upper(),
url, kwargs))
resp = call(url, **kwargs)
if self.debug:
print("-- response: %s " % resp.text)
if resp.status_code != 200:
raise LunrHttpError("%s returned '%s' with '%s'" %
(url, resp.status_code,
json.loads(resp.text)['reason']),
resp.status_code)
return response(json.loads(resp.text), resp.status_code)
except requests.RequestException as e:
raise LunrError(str(e))
评论列表
文章目录