代码格式化
This commit is contained in:
parent
2a9c70eee5
commit
821d6cf2db
|
@ -1 +0,0 @@
|
|||
from rest_framework import serializers
|
|
@ -56,7 +56,7 @@ class EmployeeCreateUpdateSerializer(EmployeeBaseSerializer):
|
|||
if instance.belong_dept:
|
||||
try:
|
||||
departmentId = instance.belong_dept.third_info['dh_id']
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
json_data = {
|
||||
"service": "ehs",
|
||||
|
@ -116,7 +116,7 @@ class EmployeeCreateUpdateSerializer(EmployeeBaseSerializer):
|
|||
if instance.belong_dept:
|
||||
try:
|
||||
departmentId = instance.belong_dept.third_info['dh_id']
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
if dhClient:
|
||||
third_info = instance.third_info
|
||||
|
|
|
@ -122,7 +122,7 @@ class LogDetailView(APIView):
|
|||
with open(os.path.join(settings.LOG_PATH, name)) as f:
|
||||
data = f.read()
|
||||
return Response(data)
|
||||
except:
|
||||
except Exception:
|
||||
raise NotFound(**LOG_NOT_FONED)
|
||||
|
||||
|
||||
|
|
|
@ -25,8 +25,6 @@ class DahuaTestView(MyLoggingMixin, APIView):
|
|||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
# file_path_rela = '/media/default/avatar.png'
|
||||
# _, res = dhClient.request(**dhapis['person_img_upload'], file_path_rela=file_path_rela)
|
||||
_, res = dhClient.request(
|
||||
url='/evo-apigw/evo-brm/1.0.0/person/subsystem/{}'.format(2059335),
|
||||
method='get')
|
||||
|
@ -79,9 +77,8 @@ class XxCommonViewSet(CreateModelMixin, CustomGenericViewSet):
|
|||
serializer.is_valid(raise_exception=True)
|
||||
vdata = serializer.validated_data
|
||||
if vdata.get('code', ''):
|
||||
try:
|
||||
dhapi = dhapis[vdata['code']]
|
||||
except:
|
||||
dhapi = dhapis.get(vdata['code'], None)
|
||||
if dhapi is None:
|
||||
raise ParseError(**TAPI_CODE_WRONG)
|
||||
vdata['url'] = dhapi['url']
|
||||
vdata['method'] = dhapi['method']
|
||||
|
@ -92,7 +89,8 @@ class XxCommonViewSet(CreateModelMixin, CustomGenericViewSet):
|
|||
json=vdata.get('json', {}))
|
||||
return Response(res)
|
||||
|
||||
@action(methods=['get'], detail=False, permission_classes=[IsAuthenticated])
|
||||
@action(methods=['get'], detail=False,
|
||||
permission_classes=[IsAuthenticated])
|
||||
def codes(self, request, pk=None):
|
||||
"""获取请求短标识
|
||||
|
||||
|
@ -113,9 +111,8 @@ class DhCommonViewSet(CreateModelMixin, CustomGenericViewSet):
|
|||
serializer.is_valid(raise_exception=True)
|
||||
vdata = serializer.validated_data
|
||||
if vdata.get('code', ''):
|
||||
try:
|
||||
xxapi = xxapis[vdata['code']]
|
||||
except:
|
||||
xxapi = xxapis.get(vdata['code'], None)
|
||||
if xxapi is None:
|
||||
raise ParseError(**TAPI_CODE_WRONG)
|
||||
vdata['url'] = xxapi['url']
|
||||
vdata['method'] = xxapi['method']
|
||||
|
@ -126,7 +123,8 @@ class DhCommonViewSet(CreateModelMixin, CustomGenericViewSet):
|
|||
json=vdata.get('json', {}))
|
||||
return Response(res)
|
||||
|
||||
@action(methods=['get'], detail=False, permission_classes=[IsAuthenticated])
|
||||
@action(methods=['get'], detail=False,
|
||||
permission_classes=[IsAuthenticated])
|
||||
def codes(self, request, pk=None):
|
||||
"""获取请求短标识
|
||||
|
||||
|
@ -134,7 +132,8 @@ class DhCommonViewSet(CreateModelMixin, CustomGenericViewSet):
|
|||
"""
|
||||
return Response(dhapis)
|
||||
|
||||
@action(methods=['post'], detail=False, permission_classes=[IsAdminUser],
|
||||
@action(methods=['post'], detail=False,
|
||||
permission_classes=[IsAdminUser],
|
||||
serializer_class=serializers.Serializer)
|
||||
def subscribe(self, request, pk=None):
|
||||
"""事件订阅
|
||||
|
@ -170,14 +169,16 @@ class DhCommonViewSet(CreateModelMixin, CustomGenericViewSet):
|
|||
dhClient.request(**dhapis['mq_subscribe'], json=json_data)
|
||||
return Response()
|
||||
|
||||
@action(methods=['delete'], detail=False, permission_classes=[IsAdminUser],
|
||||
@action(methods=['delete'], detail=False,
|
||||
permission_classes=[IsAdminUser],
|
||||
serializer_class=serializers.Serializer)
|
||||
def unsubscribe(self, request, pk=None):
|
||||
"""取消事件订阅
|
||||
|
||||
取消事件订阅
|
||||
"""
|
||||
dhClient.request(**dhapis['mq_unsubscribe'], params={'name': '127.0.0.1_8000'})
|
||||
dhClient.request(**dhapis['mq_unsubscribe'],
|
||||
params={'name': '127.0.0.1_8000'})
|
||||
return Response()
|
||||
|
||||
@action(methods=['post'], detail=False,
|
||||
|
|
|
@ -27,7 +27,7 @@ def get_request_data(request):
|
|||
body = request.body
|
||||
if body:
|
||||
data = json.loads(body)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
pass
|
||||
if not isinstance(data, dict):
|
||||
data = {'data': data}
|
||||
|
@ -103,6 +103,6 @@ def get_verbose_name(queryset=None, view=None, model=None):
|
|||
return getattr(model, '_meta').verbose_name
|
||||
else:
|
||||
model = queryset.model._meta.verbose_name
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
pass
|
||||
return model if model else ""
|
||||
|
|
|
@ -46,5 +46,5 @@ class SignatureViewSet(CustomCreateModelMixin, CustomGenericViewSet):
|
|||
new_path = ext[0] + '.png'
|
||||
cv2.imwrite(new_path, image)
|
||||
return Response({'path': new_path.replace(BASE_DIR, '')})
|
||||
except:
|
||||
except Exception:
|
||||
raise ParseError(**SIGN_MAKE_FAIL)
|
||||
|
|
|
@ -32,7 +32,7 @@ class WfService(object):
|
|||
try:
|
||||
wf_state_obj = State.objects.get(workflow=workflow, type=State.STATE_TYPE_START, is_deleted=False)
|
||||
return wf_state_obj
|
||||
except:
|
||||
except Exception:
|
||||
raise APIException('工作流状态配置错误')
|
||||
|
||||
@staticmethod
|
||||
|
@ -43,7 +43,7 @@ class WfService(object):
|
|||
try:
|
||||
wf_state_obj = State.objects.get(workflow=workflow, type=State.STATE_TYPE_END, is_deleted=False)
|
||||
return wf_state_obj
|
||||
except:
|
||||
except Exception:
|
||||
raise APIException('工作流状态配置错误')
|
||||
|
||||
@staticmethod
|
||||
|
|
Loading…
Reference in New Issue