def request(self, *args, **kwargs):
response = super(Session, self).request(*args, **kwargs)
content_type = response.headers.get('Content-Type', '').split(';')[0]
json_mimetypes = ['application/json', 'text/json']
if content_type not in json_mimetypes:
return response
try:
json = response.json()
except:
return response
reason = json.get('errorMessage') or json.get('reason')
if not reason and isinstance(json.get('error'), six.string_types):
reason = json.get('error')
if not reason and not response.ok:
reason = response.reason
if not reason and json.get('error'):
reason = "Unknown reason"
code = json.get('errorCode')
if reason:
raise Exception
return response
apple_calendar_api.py 文件源码
python
阅读 29
收藏 0
点赞 0
评论 0
评论列表
文章目录