合并冲突
This commit is contained in:
commit
2e67bcd48b
|
@ -6,9 +6,9 @@ import traceback
|
|||
import uuid
|
||||
|
||||
import requests
|
||||
from requests.exceptions import RequestException
|
||||
from django.conf import settings
|
||||
from rest_framework.exceptions import APIException, ParseError
|
||||
from requests.exceptions import RequestException
|
||||
|
||||
from apps.third.errors import DH_REQUEST_ERROR
|
||||
from apps.third.models import Tlog
|
||||
|
@ -67,8 +67,8 @@ class DhClient:
|
|||
self.log.update({"path": url})
|
||||
try:
|
||||
r = getattr(requests, method)('{}{}'.format(settings.DAHUA_BASE_URL, url),
|
||||
headers=self.headers, params=params, json=json,
|
||||
timeout=timeout, files=files, verify=False)
|
||||
headers=self.headers, params=params, json=json,
|
||||
timeout=timeout, files=files, verify=False)
|
||||
# if settings.DEBUG:
|
||||
# print_roundtrip(r)
|
||||
ret = r.text
|
||||
|
@ -77,7 +77,7 @@ class DhClient:
|
|||
if ret['code'] not in ['0', '100', '00000', '1000', 0, 100, 1000]:
|
||||
detail = '大华错误:' + \
|
||||
'{}|{}{}{}'.format(str(ret['code']), ret.get('errMsg', ''),
|
||||
ret.get('desc', ''), str(ret.get('data', '')))
|
||||
ret.get('desc', ''), str(ret.get('data', '')))
|
||||
err_detail = dict(detail=detail, code='dh_'+str(ret['code']))
|
||||
self.handle_log(result='fail', response=ret)
|
||||
if raise_exception:
|
||||
|
|
|
@ -5,9 +5,9 @@ import uuid
|
|||
import logging
|
||||
|
||||
import requests
|
||||
from requests.exceptions import RequestException
|
||||
from rest_framework.exceptions import APIException, ParseError
|
||||
from django.conf import settings
|
||||
from requests.exceptions import RequestException
|
||||
|
||||
from apps.third.errors import SP_REQUEST_ERROR
|
||||
from apps.third.models import Tlog
|
||||
|
@ -64,8 +64,8 @@ class SpClient:
|
|||
url = url.format(**params)
|
||||
try:
|
||||
r = getattr(requests, method)('{}{}'.format(settings.SP_BASE_URL, url),
|
||||
headers=self.headers, params=params, json=json,
|
||||
timeout=timeout, files=files, verify=False)
|
||||
headers=self.headers, params=params, json=json,
|
||||
timeout=timeout, files=files, verify=False)
|
||||
# if settings.DEBUG:
|
||||
# print_roundtrip(r)
|
||||
ret = r.text
|
||||
|
|
|
@ -4,9 +4,9 @@ from threading import Thread
|
|||
import traceback
|
||||
import uuid
|
||||
import requests
|
||||
from requests.exceptions import RequestException
|
||||
from django.conf import settings
|
||||
from rest_framework.exceptions import APIException, ParseError
|
||||
from requests.exceptions import RequestException
|
||||
|
||||
from apps.third.errors import XX_REQUEST_ERROR
|
||||
from apps.third.models import Tlog
|
||||
|
@ -55,7 +55,7 @@ class XxClient:
|
|||
"params": params, "body": json, "target": "xunxi", "result": 10, "headers": self.headers}
|
||||
try:
|
||||
r = getattr(requests, method)('{}{}'.format(settings.XX_BASE_URL, url),
|
||||
headers=self.headers, params=params, json=json, timeout=timeout, verify=False)
|
||||
headers=self.headers, params=params, json=json, timeout=timeout, verify=False)
|
||||
# if settings.DEBUG:
|
||||
# print_roundtrip(r)
|
||||
ret = r.text
|
||||
|
@ -67,7 +67,7 @@ class XxClient:
|
|||
# self.request(url, method, params, json, timeout, raise_exception) # 重新请求
|
||||
# return
|
||||
err_detail = dict(detail='寻息错误:' + '|'.join(ret['errorMsg']),
|
||||
code='xx_' + str(ret['errorCode']))
|
||||
code='xx_' + str(ret['errorCode']))
|
||||
self.handle_log(result='fail', response=ret)
|
||||
if raise_exception:
|
||||
raise ParseError(**err_detail)
|
||||
|
|
Loading…
Reference in New Issue