third dahua xunxi speaker 优化2
This commit is contained in:
parent
7e3a1f4f78
commit
cf0ac02660
|
@ -8,7 +8,6 @@ import uuid
|
|||
import requests
|
||||
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
|
||||
|
@ -85,8 +84,8 @@ class DhClient:
|
|||
return 'fail', err_detail
|
||||
# self.handle_log(result='success', response=ret) # 成功的日志就不记录了
|
||||
return 'success', ret['data'] if 'data' in ret else None
|
||||
except RequestException:
|
||||
self.handle_log(result='error', response=None)
|
||||
except Exception:
|
||||
self.handle_log(result='error', response=None, errors=traceback.format_exc())
|
||||
if raise_exception:
|
||||
raise APIException(**DH_REQUEST_ERROR)
|
||||
return 'error', DH_REQUEST_ERROR
|
||||
|
|
|
@ -7,7 +7,6 @@ import logging
|
|||
import requests
|
||||
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
|
||||
|
@ -80,8 +79,8 @@ class SpClient:
|
|||
return 'fail', err_detail
|
||||
# self.handle_log(result='success', response=ret)
|
||||
return 'success', ret
|
||||
except RequestException:
|
||||
self.handle_log(result='error', response=None)
|
||||
except Exception:
|
||||
self.handle_log(result='error', response=None, errors=traceback.format_exc())
|
||||
if raise_exception:
|
||||
raise APIException(**SP_REQUEST_ERROR)
|
||||
return 'error', SP_REQUEST_ERROR
|
||||
|
|
|
@ -6,7 +6,6 @@ import uuid
|
|||
import requests
|
||||
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
|
||||
|
@ -73,8 +72,8 @@ class XxClient:
|
|||
raise ParseError(**err_detail)
|
||||
return 'fail', err_detail
|
||||
return 'success', ret['data']
|
||||
except RequestException:
|
||||
self.handle_log(result='error', response=None)
|
||||
except Exception:
|
||||
self.handle_log(result='error', response=None, errors=traceback.format_exc())
|
||||
if raise_exception:
|
||||
raise APIException(**XX_REQUEST_ERROR)
|
||||
return 'error', XX_REQUEST_ERROR
|
||||
|
|
Loading…
Reference in New Issue