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