diff --git a/apps/develop/serializers.py b/apps/develop/serializers.py index bd7363c0..e69de29b 100755 --- a/apps/develop/serializers.py +++ b/apps/develop/serializers.py @@ -1 +0,0 @@ -from rest_framework import serializers \ No newline at end of file diff --git a/apps/hrm/serializers.py b/apps/hrm/serializers.py index 4286d1f2..9e1a9272 100755 --- a/apps/hrm/serializers.py +++ b/apps/hrm/serializers.py @@ -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 diff --git a/apps/monitor/views.py b/apps/monitor/views.py index df636ded..841d6ec2 100755 --- a/apps/monitor/views.py +++ b/apps/monitor/views.py @@ -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) diff --git a/apps/third/views.py b/apps/third/views.py index aa61ad09..c85541d0 100755 --- a/apps/third/views.py +++ b/apps/third/views.py @@ -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, diff --git a/apps/utils/request.py b/apps/utils/request.py index 8e7d3656..e9482151 100755 --- a/apps/utils/request.py +++ b/apps/utils/request.py @@ -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 "" diff --git a/apps/utils/views.py b/apps/utils/views.py index db4b3dd4..a2157471 100755 --- a/apps/utils/views.py +++ b/apps/utils/views.py @@ -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) diff --git a/apps/wf/services.py b/apps/wf/services.py index a4538f5b..029ef918 100755 --- a/apps/wf/services.py +++ b/apps/wf/services.py @@ -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