三方接口处理问题
This commit is contained in:
parent
f7b8186e55
commit
574254f7bc
|
@ -82,6 +82,7 @@ class DhClient:
|
||||||
timeout=timeout, files=files, verify=False)
|
timeout=timeout, files=files, verify=False)
|
||||||
# if settings.DEBUG:
|
# if settings.DEBUG:
|
||||||
# print_roundtrip(r)
|
# print_roundtrip(r)
|
||||||
|
ret = r.text
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
ret = r.json()
|
ret = r.json()
|
||||||
if ret['code'] not in ['0', '100', '00000', '1000', 0, 100, 1000]:
|
if ret['code'] not in ['0', '100', '00000', '1000', 0, 100, 1000]:
|
||||||
|
@ -95,8 +96,6 @@ class DhClient:
|
||||||
return 'fail', err_detail
|
return 'fail', err_detail
|
||||||
# self.handle_log(result='success', response=ret) # 成功的日志就不记录了
|
# self.handle_log(result='success', response=ret) # 成功的日志就不记录了
|
||||||
return 'success', ret['data'] if 'data' in ret else None
|
return 'success', ret['data'] if 'data' in ret else None
|
||||||
else:
|
|
||||||
ret = r.text
|
|
||||||
self.handle_log(result='error', response=ret)
|
self.handle_log(result='error', response=ret)
|
||||||
if raise_exception:
|
if raise_exception:
|
||||||
raise APIException(**DH_REQUEST_ERROR)
|
raise APIException(**DH_REQUEST_ERROR)
|
||||||
|
|
|
@ -78,6 +78,7 @@ class SpClient:
|
||||||
timeout=timeout, files=files, verify=False)
|
timeout=timeout, files=files, verify=False)
|
||||||
# if settings.DEBUG:
|
# if settings.DEBUG:
|
||||||
# print_roundtrip(r)
|
# print_roundtrip(r)
|
||||||
|
ret = r.text
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
ret = r.json()
|
ret = r.json()
|
||||||
if 'code' in ret and ret['code'] not in ['0', '100', '00000', '1000', 0, 100, 1000]:
|
if 'code' in ret and ret['code'] not in ['0', '100', '00000', '1000', 0, 100, 1000]:
|
||||||
|
@ -89,8 +90,6 @@ class SpClient:
|
||||||
return 'fail', err_detail
|
return 'fail', err_detail
|
||||||
# self.handle_log(result='success', response=ret)
|
# self.handle_log(result='success', response=ret)
|
||||||
return 'success', ret
|
return 'success', ret
|
||||||
else:
|
|
||||||
ret = r.text
|
|
||||||
self.handle_log(result='error', response=ret)
|
self.handle_log(result='error', response=ret)
|
||||||
if raise_exception:
|
if raise_exception:
|
||||||
raise APIException(**SP_REQUEST_ERROR)
|
raise APIException(**SP_REQUEST_ERROR)
|
||||||
|
|
Loading…
Reference in New Issue