diff --git a/app_desc.yaml b/app_desc.yaml index 77e1c02fa0..e0ff870406 100644 --- a/app_desc.yaml +++ b/app_desc.yaml @@ -1,5 +1,5 @@ spec_version: 2 -app_version: "1.11.2" +app_version: "1.12.0" app: region: default bk_app_code: &APP_CODE bk_flow_engine diff --git a/bkflow/admin/models.py b/bkflow/admin/models.py index 7a8ee15947..a55d528737 100644 --- a/bkflow/admin/models.py +++ b/bkflow/admin/models.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -20,7 +19,7 @@ from enum import Enum from django.db import models -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ class ModuleType(Enum): diff --git a/bkflow/admin/urls.py b/bkflow/admin/urls.py index 1649b31a43..2118f13373 100644 --- a/bkflow/admin/urls.py +++ b/bkflow/admin/urls.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -19,7 +18,8 @@ """ -from django.conf.urls import include, url +from django.conf.urls import include +from django.urls import re_path from rest_framework.routers import DefaultRouter from bkflow.admin.views import ModuleInfoAdminViewSet @@ -28,5 +28,5 @@ router.register(r"^module_info", ModuleInfoAdminViewSet, basename="module_info") urlpatterns = [ - url(r"^", include(router.urls)), + re_path(r"^", include(router.urls)), ] diff --git a/bkflow/apigw/exceptions.py b/bkflow/apigw/exceptions.py index e5f0f7b647..f8bc43a9ac 100644 --- a/bkflow/apigw/exceptions.py +++ b/bkflow/apigw/exceptions.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -17,7 +16,7 @@ to the current version of the project delivered to anyone in the future. """ -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from bkflow.exceptions import BKFLOWException diff --git a/bkflow/apigw/serializers/credential.py b/bkflow/apigw/serializers/credential.py index a826b22a30..af5b10d51e 100644 --- a/bkflow/apigw/serializers/credential.py +++ b/bkflow/apigw/serializers/credential.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -17,7 +16,7 @@ to the current version of the project delivered to anyone in the future. """ -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from rest_framework import serializers from bkflow.space.credential import BkAppCredential diff --git a/bkflow/apigw/serializers/space.py b/bkflow/apigw/serializers/space.py index c62ba40ceb..f967e4c169 100644 --- a/bkflow/apigw/serializers/space.py +++ b/bkflow/apigw/serializers/space.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -18,7 +17,7 @@ to the current version of the project delivered to anyone in the future. """ -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from rest_framework import serializers from bkflow.exceptions import ValidationError diff --git a/bkflow/apigw/serializers/space_config.py b/bkflow/apigw/serializers/space_config.py index 40b3a4d1e9..31c8a9ce83 100644 --- a/bkflow/apigw/serializers/space_config.py +++ b/bkflow/apigw/serializers/space_config.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -17,7 +16,7 @@ to the current version of the project delivered to anyone in the future. """ -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from rest_framework import serializers from bkflow.exceptions import ValidationError diff --git a/bkflow/apigw/serializers/task.py b/bkflow/apigw/serializers/task.py index e21006ea05..d0e9f7ace1 100644 --- a/bkflow/apigw/serializers/task.py +++ b/bkflow/apigw/serializers/task.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -17,7 +16,7 @@ to the current version of the project delivered to anyone in the future. """ -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.exceptions import PipelineException from rest_framework import serializers diff --git a/bkflow/apigw/serializers/template.py b/bkflow/apigw/serializers/template.py index b9187aa2ac..790b89ec15 100644 --- a/bkflow/apigw/serializers/template.py +++ b/bkflow/apigw/serializers/template.py @@ -18,7 +18,7 @@ """ import logging -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.validators import validate_pipeline_tree from rest_framework import serializers diff --git a/bkflow/apigw/serializers/token.py b/bkflow/apigw/serializers/token.py index 1843ceaea2..d5a54c7073 100644 --- a/bkflow/apigw/serializers/token.py +++ b/bkflow/apigw/serializers/token.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -19,7 +18,7 @@ """ import logging -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from rest_framework import serializers from bkflow.apigw.exceptions import CreateTokenException diff --git a/bkflow/apigw/urls.py b/bkflow/apigw/urls.py index 329fd75085..f2211c4bc2 100644 --- a/bkflow/apigw/urls.py +++ b/bkflow/apigw/urls.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -18,7 +17,7 @@ to the current version of the project delivered to anyone in the future. """ from django.conf import settings -from django.conf.urls import url +from django.urls import re_path from module_settings import BKFLOWModuleType @@ -56,35 +55,37 @@ from bkflow.apigw.views.validate_pipeline_tree import validate_pipeline_tree urlpatterns += [ - url(r"^create_space/$", create_space), - url(r"^grant_apigw_permissions_to_app/$", grant_apigw_permissions_to_app), - url(r"^space/(?P\d+)/apply_token/$", apply_token), - url(r"^space/(?P\d+)/revoke_token/$", revoke_token), - url(r"^space/(?P\d+)/create_template/$", create_template), - url(r"^space/(?P\d+)/get_template_list/$", get_template_list), - url(r"^space/(?P\d+)/template/(?P\d+)/get_template_detail/$", get_template_detail), - url(r"^space/(?P\d+)/template/(?P\d+)/get_template_mock_data/$", get_template_mock_data), - url(r"^space/(?P\d+)/renew_space_config/$", renew_space_config), - url(r"^space/(?P\d+)/get_space_configs/$", get_space_configs), - url(r"^space/(?P\d+)/update_template/(?P\d+)/$", update_template), - url(r"^space/(?P\d+)/delete_template/(?P\d+)/$", delete_template), - url(r"^space/(?P\d+)/create_task/$", create_task), - url(r"^space/(?P\d+)/create_mock_task/$", create_mock_task), - url(r"^space/(?P\d+)/create_task_without_template/$", create_task_without_template), - url(r"^space/(?P\d+)/validate_pipeline_tree/$", validate_pipeline_tree), - url(r"^space/(?P\d+)/create_credential/$", create_credential), - url(r"^space/(?P\d+)/get_task_list/$", get_task_list), - url(r"^space/(?P\d+)/task/(?P\d+)/get_task_detail/$", get_task_detail), - url(r"^space/(?P\d+)/task/(?P\d+)/get_task_states/$", get_task_states), - url(r"^space/(?P\d+)/get_tasks_states/$", get_tasks_states), - url( + re_path(r"^create_space/$", create_space), + re_path(r"^grant_apigw_permissions_to_app/$", grant_apigw_permissions_to_app), + re_path(r"^space/(?P\d+)/apply_token/$", apply_token), + re_path(r"^space/(?P\d+)/revoke_token/$", revoke_token), + re_path(r"^space/(?P\d+)/create_template/$", create_template), + re_path(r"^space/(?P\d+)/get_template_list/$", get_template_list), + re_path(r"^space/(?P\d+)/template/(?P\d+)/get_template_detail/$", get_template_detail), + re_path( + r"^space/(?P\d+)/template/(?P\d+)/get_template_mock_data/$", get_template_mock_data + ), + re_path(r"^space/(?P\d+)/renew_space_config/$", renew_space_config), + re_path(r"^space/(?P\d+)/get_space_configs/$", get_space_configs), + re_path(r"^space/(?P\d+)/update_template/(?P\d+)/$", update_template), + re_path(r"^space/(?P\d+)/delete_template/(?P\d+)/$", delete_template), + re_path(r"^space/(?P\d+)/create_task/$", create_task), + re_path(r"^space/(?P\d+)/create_mock_task/$", create_mock_task), + re_path(r"^space/(?P\d+)/create_task_without_template/$", create_task_without_template), + re_path(r"^space/(?P\d+)/validate_pipeline_tree/$", validate_pipeline_tree), + re_path(r"^space/(?P\d+)/create_credential/$", create_credential), + re_path(r"^space/(?P\d+)/get_task_list/$", get_task_list), + re_path(r"^space/(?P\d+)/task/(?P\d+)/get_task_detail/$", get_task_detail), + re_path(r"^space/(?P\d+)/task/(?P\d+)/get_task_states/$", get_task_states), + re_path(r"^space/(?P\d+)/get_tasks_states/$", get_tasks_states), + re_path( r"^space/(?P\d+)/task/(?P\d+)/node/(?P\w+)/get_task_node_detail/$", get_task_node_detail, ), - url( + re_path( r"^space/(?P\d+)/task/(?P\d+)/node/(?P\w+)/operate_node/(?P\w+)/$", operate_task_node, ), - url(r"^space/(?P\d+)/task/(?P\d+)/operate_task/(?P\w+)/$", operate_task), - url(r"^space/(?P\d+)/apply_webhook_configs/$", apply_webhook_configs), + re_path(r"^space/(?P\d+)/task/(?P\d+)/operate_task/(?P\w+)/$", operate_task), + re_path(r"^space/(?P\d+)/apply_webhook_configs/$", apply_webhook_configs), ] diff --git a/bkflow/apigw/views/apply_token.py b/bkflow/apigw/views/apply_token.py index 87e12ebac3..13e40a68b1 100644 --- a/bkflow/apigw/views/apply_token.py +++ b/bkflow/apigw/views/apply_token.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -24,7 +23,7 @@ from apigw_manager.apigw.decorators import apigw_require from blueapps.account.decorators import login_exempt from django.utils import timezone -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.views.decorators.csrf import csrf_exempt from django.views.decorators.http import require_POST from pytimeparse import parse diff --git a/bkflow/apigw/views/create_mock_task.py b/bkflow/apigw/views/create_mock_task.py index fb3b74fd58..109e8e2dab 100644 --- a/bkflow/apigw/views/create_mock_task.py +++ b/bkflow/apigw/views/create_mock_task.py @@ -20,7 +20,7 @@ from apigw_manager.apigw.decorators import apigw_require from blueapps.account.decorators import login_exempt -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.views.decorators.csrf import csrf_exempt from django.views.decorators.http import require_POST diff --git a/bkflow/apigw/views/create_task.py b/bkflow/apigw/views/create_task.py index b1abd3c95a..6be59b9d20 100644 --- a/bkflow/apigw/views/create_task.py +++ b/bkflow/apigw/views/create_task.py @@ -20,7 +20,7 @@ from apigw_manager.apigw.decorators import apigw_require from blueapps.account.decorators import login_exempt -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.views.decorators.csrf import csrf_exempt from django.views.decorators.http import require_POST diff --git a/bkflow/apigw/views/update_template.py b/bkflow/apigw/views/update_template.py index 4121a09e25..2f4cdf8426 100644 --- a/bkflow/apigw/views/update_template.py +++ b/bkflow/apigw/views/update_template.py @@ -19,7 +19,7 @@ import json from blueapps.account.decorators import login_exempt -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.views.decorators.csrf import csrf_exempt from django.views.decorators.http import require_POST diff --git a/bkflow/bk_plugin/models.py b/bkflow/bk_plugin/models.py index 6c406b99f2..47ee0557cf 100644 --- a/bkflow/bk_plugin/models.py +++ b/bkflow/bk_plugin/models.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -22,7 +21,7 @@ from django.db import models, transaction from django.utils.timezone import localtime -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ import env from bkflow.constants import ALL_SPACE, WHITE_LIST diff --git a/bkflow/bk_plugin/urls.py b/bkflow/bk_plugin/urls.py index 821d2bc6fb..f856635ec1 100644 --- a/bkflow/bk_plugin/urls.py +++ b/bkflow/bk_plugin/urls.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -23,6 +22,6 @@ router = DefaultRouter() router.register(r"manager", views.BKPluginManagerViewSet) -router.register(r"", views.BKPluginViewSet) +router.register(r"", views.BKPluginViewSet, "bkplugin_base") urlpatterns = router.urls diff --git a/bkflow/constants.py b/bkflow/constants.py index 6416f58fe9..cd1e252f07 100644 --- a/bkflow/constants.py +++ b/bkflow/constants.py @@ -19,7 +19,7 @@ import re from enum import Enum -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ MAX_LEN_OF_TASK_NAME = 128 MAX_LEN_OF_TEMPLATE_NAME = 128 diff --git a/bkflow/contrib/operation_record/models.py b/bkflow/contrib/operation_record/models.py index dd6435b781..a9b11f3549 100644 --- a/bkflow/contrib/operation_record/models.py +++ b/bkflow/contrib/operation_record/models.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -18,7 +17,7 @@ to the current version of the project delivered to anyone in the future. """ from django.db import models -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ class BaseOperateRecord(models.Model): diff --git a/bkflow/decision_table/urls.py b/bkflow/decision_table/urls.py index 5429bca704..5470016b28 100644 --- a/bkflow/decision_table/urls.py +++ b/bkflow/decision_table/urls.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -17,8 +16,7 @@ to the current version of the project delivered to anyone in the future. """ -from django.conf.urls import url -from django.urls import include +from django.urls import include, re_path from rest_framework.routers import DefaultRouter from bkflow.decision_table.views import ( @@ -34,5 +32,5 @@ urlpatterns = [ - url(r"", include(drf_router.urls)), + re_path(r"", include(drf_router.urls)), ] diff --git a/bkflow/interface/task/urls.py b/bkflow/interface/task/urls.py index 24dda8b3a8..06146d112f 100644 --- a/bkflow/interface/task/urls.py +++ b/bkflow/interface/task/urls.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -17,8 +16,7 @@ to the current version of the project delivered to anyone in the future. """ -from django.conf.urls import url -from django.urls import include +from django.urls import include, re_path from rest_framework.routers import DefaultRouter from bkflow.interface.task.view import ( @@ -32,4 +30,4 @@ drf_router.register(r"task_admin", TaskInterfaceAdminViewSet, basename="task_admin") drf_router.register(r"task_system_superuser", TaskInterfaceSystemSuperuserViewSet, basename="task_system_superuser") -urlpatterns = [url(r"", include(drf_router.urls))] +urlpatterns = [re_path(r"", include(drf_router.urls))] diff --git a/bkflow/interface/task/view.py b/bkflow/interface/task/view.py index 8e4f02647d..7a6845f37a 100644 --- a/bkflow/interface/task/view.py +++ b/bkflow/interface/task/view.py @@ -19,7 +19,7 @@ import logging from django.utils import timezone -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from drf_yasg.utils import swagger_auto_schema from rest_framework.decorators import action from rest_framework.response import Response diff --git a/bkflow/interface/urls.py b/bkflow/interface/urls.py index 7b0c78ab47..5fb2b2980b 100644 --- a/bkflow/interface/urls.py +++ b/bkflow/interface/urls.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -17,8 +16,7 @@ to the current version of the project delivered to anyone in the future. """ -from django.conf.urls import url -from django.urls import include +from django.urls import include, re_path from .itsm.itsm import itsm_approve from .views import ( @@ -31,12 +29,12 @@ ) urlpatterns = [ - url(r"^$", home), - url(r"^logout/$", user_exit), - url(r"^is_admin_user/$", is_admin_or_space_superuser), - url(r"^is_current_space_admin/$", is_admin_or_current_space_superuser), - url(r"^callback/(?P.+)/$", callback), - url(r"^get_msg_types/$", get_msg_types), - url(r"^itsm_approve/$", itsm_approve), - url(r"", include("bkflow.interface.task.urls")), + re_path(r"^$", home), + re_path(r"^logout/$", user_exit), + re_path(r"^is_admin_user/$", is_admin_or_space_superuser), + re_path(r"^is_current_space_admin/$", is_admin_or_current_space_superuser), + re_path(r"^callback/(?P.+)/$", callback), + re_path(r"^get_msg_types/$", get_msg_types), + re_path(r"^itsm_approve/$", itsm_approve), + re_path(r"", include("bkflow.interface.task.urls")), ] diff --git a/bkflow/interface/views.py b/bkflow/interface/views.py index 0088048b28..386ded402f 100644 --- a/bkflow/interface/views.py +++ b/bkflow/interface/views.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -30,7 +29,7 @@ from django.contrib.auth import logout from django.http import JsonResponse from django.shortcuts import render -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.views.decorators.csrf import csrf_exempt from django.views.decorators.http import require_GET, require_POST @@ -115,9 +114,7 @@ def callback(request, token): try: callback_data = json.loads(request.body) except Exception: - message = _("节点回调失败: 无效的请求, 请重试. 如持续失败可联系管理员处理. {msg} | api callback").format( - msg=traceback.format_exc() - ) + message = _("节点回调失败: 无效的请求, 请重试. 如持续失败可联系管理员处理. {msg} | api callback").format(msg=traceback.format_exc()) logger.error(message) return JsonResponse({"result": False, "message": message}, status=400) diff --git a/bkflow/permission/exceptions.py b/bkflow/permission/exceptions.py index 774c581d69..8be4c47a3b 100644 --- a/bkflow/permission/exceptions.py +++ b/bkflow/permission/exceptions.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -17,7 +16,7 @@ to the current version of the project delivered to anyone in the future. """ -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from bkflow.exceptions import BKFLOWException diff --git a/bkflow/permission/models.py b/bkflow/permission/models.py index 5f0982ef12..9e7548f128 100644 --- a/bkflow/permission/models.py +++ b/bkflow/permission/models.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -25,7 +24,7 @@ from django.db import models from django.db.models.query import QuerySet from django.utils import timezone -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pytimeparse import parse from bkflow.space.configs import TokenAutoRenewalConfig, TokenExpirationConfig diff --git a/bkflow/permission/tasks.py b/bkflow/permission/tasks.py index 2c20f2e457..9b46ec16fd 100644 --- a/bkflow/permission/tasks.py +++ b/bkflow/permission/tasks.py @@ -16,7 +16,7 @@ to the current version of the project delivered to anyone in the future. """ -import datetime +from datetime import timedelta from blueapps.contrib.celery_tools.periodic import periodic_task from celery.schedules import crontab @@ -30,6 +30,7 @@ def delete_expired_token(): # 假设token的过期时间为一小时,一天有2000个用户操作了100个流程,会生成大概200000个token # 此时的批量删除的数量级大概是可以接受的 - Token.objects.filter( - expired_time__lt=timezone.now() - datetime.timedelta(seconds=settings.TOKEN_RETENTION_TIME) - ).delete() + retention_period = timedelta(seconds=settings.TOKEN_RETENTION_TIME) + cutoff_time = timezone.now() - retention_period + + Token.objects.filter(expired_time__lt=cutoff_time).delete() diff --git a/bkflow/permission/urls.py b/bkflow/permission/urls.py index 8f9aea6805..bbf40d2ea7 100644 --- a/bkflow/permission/urls.py +++ b/bkflow/permission/urls.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -17,7 +16,8 @@ to the current version of the project delivered to anyone in the future. """ -from django.conf.urls import include, url +from django.conf.urls import include +from django.urls import re_path from rest_framework.routers import DefaultRouter from bkflow.permission.views import TokenViewSet @@ -26,5 +26,5 @@ router.register(r"token", TokenViewSet, basename="token") urlpatterns = [ - url(r"^", include(router.urls)), + re_path(r"^", include(router.urls)), ] diff --git a/bkflow/permission/views.py b/bkflow/permission/views.py index 5e915937e9..274b1382f6 100644 --- a/bkflow/permission/views.py +++ b/bkflow/permission/views.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -20,7 +19,7 @@ from datetime import datetime -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from drf_yasg.utils import swagger_auto_schema from rest_framework.decorators import action from rest_framework.response import Response diff --git a/bkflow/pipeline_plugins/components/collections/approve/v1_0.py b/bkflow/pipeline_plugins/components/collections/approve/v1_0.py index f56bc81715..712113cb81 100644 --- a/bkflow/pipeline_plugins/components/collections/approve/v1_0.py +++ b/bkflow/pipeline_plugins/components/collections/approve/v1_0.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -22,7 +21,7 @@ import traceback from django.conf import settings -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.component_framework.component import Component from pipeline.core.flow.io import StringItemSchema @@ -61,9 +60,7 @@ def inputs_format(self): def outputs_format(self): return [ - self.OutputItem( - name=_("单据sn"), key="sn", type="string", schema=StringItemSchema(description=_("单据sn")) - ), + self.OutputItem(name=_("单据sn"), key="sn", type="string", schema=StringItemSchema(description=_("单据sn"))), self.OutputItem( name=_("审核结果"), key="approve_result", diff --git a/bkflow/pipeline_plugins/components/collections/debug_plugin/v1_0_0.py b/bkflow/pipeline_plugins/components/collections/debug_plugin/v1_0_0.py index 1cd180ba1e..56634c0858 100644 --- a/bkflow/pipeline_plugins/components/collections/debug_plugin/v1_0_0.py +++ b/bkflow/pipeline_plugins/components/collections/debug_plugin/v1_0_0.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -20,7 +19,7 @@ import json from django.conf import settings -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.component_framework.component import Component from pipeline.core.flow.io import ( BooleanItemSchema, diff --git a/bkflow/pipeline_plugins/components/collections/display/v1_0.py b/bkflow/pipeline_plugins/components/collections/display/v1_0.py index 275f4cebc9..7f0294c3dd 100644 --- a/bkflow/pipeline_plugins/components/collections/display/v1_0.py +++ b/bkflow/pipeline_plugins/components/collections/display/v1_0.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -19,7 +18,7 @@ """ from django.conf import settings -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.component_framework.component import Component from pipeline.core.flow.io import StringItemSchema diff --git a/bkflow/pipeline_plugins/components/collections/dmn_plugin/v1_0_0.py b/bkflow/pipeline_plugins/components/collections/dmn_plugin/v1_0_0.py index 64ab79565b..9cdcc68178 100644 --- a/bkflow/pipeline_plugins/components/collections/dmn_plugin/v1_0_0.py +++ b/bkflow/pipeline_plugins/components/collections/dmn_plugin/v1_0_0.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -19,7 +18,7 @@ """ from bkflow_dmn.api import decide_single_table from django.conf import settings -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.component_framework.component import Component from pipeline.core.flow.io import ObjectItemSchema diff --git a/bkflow/pipeline_plugins/components/collections/http/v1_0.py b/bkflow/pipeline_plugins/components/collections/http/v1_0.py index 5147c9bfd5..4684f97fdf 100644 --- a/bkflow/pipeline_plugins/components/collections/http/v1_0.py +++ b/bkflow/pipeline_plugins/components/collections/http/v1_0.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -19,14 +18,12 @@ """ -from __future__ import absolute_import - import json import traceback from copy import deepcopy from django.utils import translation -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.component_framework.component import Component from pipeline.conf import settings from pipeline.core.flow.activity import StaticIntervalGenerator @@ -95,10 +92,7 @@ def inputs_format(self): key="bk_http_success_exp", type="string", schema=StringItemSchema( - description=_( - "根据返回的 JSON 的数据来控制节点的成功或失败, " - "使用 resp 引用返回的 JSON 对象,例 resp.result==True" - ) + description=_("根据返回的 JSON 的数据来控制节点的成功或失败, " "使用 resp 引用返回的 JSON 对象,例 resp.result==True") ), ), ] @@ -206,10 +200,7 @@ def __getstate__(self): class HttpComponent(Component): name = _("HTTP 请求") - desc = _( - "提示: 1.请求URL需要在当前网络下可以访问,否则会超时失败 " - "2.响应状态码在200-300(不包括300)之间,并且响应内容是 JSON 格式才会执行成功" - ) + desc = _("提示: 1.请求URL需要在当前网络下可以访问,否则会超时失败 " "2.响应状态码在200-300(不包括300)之间,并且响应内容是 JSON 格式才会执行成功") code = "bk_http_request" bound_service = HttpRequestService version = "v1.0" diff --git a/bkflow/pipeline_plugins/components/collections/pause/legacy.py b/bkflow/pipeline_plugins/components/collections/pause/legacy.py index 272f86375e..58982786fb 100644 --- a/bkflow/pipeline_plugins/components/collections/pause/legacy.py +++ b/bkflow/pipeline_plugins/components/collections/pause/legacy.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -20,7 +19,7 @@ from django.conf import settings -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.component_framework.component import Component from pipeline.core.flow.io import ObjectItemSchema, StringItemSchema @@ -70,6 +69,4 @@ class PauseComponent(Component): code = "pause_node" bound_service = PauseService form = settings.STATIC_URL + "components/pause/legacy.js" - desc = _( - "该节点可以通过node_callback API接口进行回调并传入数据,callback_data参数为dict类型,回调数据会作为该节点的输出数据" - ) + desc = _("该节点可以通过node_callback API接口进行回调并传入数据,callback_data参数为dict类型,回调数据会作为该节点的输出数据") diff --git a/bkflow/pipeline_plugins/components/collections/remote_plugin/v1_0_0.py b/bkflow/pipeline_plugins/components/collections/remote_plugin/v1_0_0.py index 797dde3943..f9cd7eb074 100644 --- a/bkflow/pipeline_plugins/components/collections/remote_plugin/v1_0_0.py +++ b/bkflow/pipeline_plugins/components/collections/remote_plugin/v1_0_0.py @@ -19,7 +19,7 @@ import logging -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.component_framework.component import Component from pipeline.core.flow.io import StringItemSchema diff --git a/bkflow/pipeline_plugins/components/collections/sleep_time/legacy.py b/bkflow/pipeline_plugins/components/collections/sleep_time/legacy.py index 8037c66388..af3214bebb 100644 --- a/bkflow/pipeline_plugins/components/collections/sleep_time/legacy.py +++ b/bkflow/pipeline_plugins/components/collections/sleep_time/legacy.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -22,10 +21,11 @@ import datetime import os import re +import zoneinfo from django.conf import settings -from django.utils import timezone, translation -from django.utils.translation import ugettext_lazy as _ +from django.utils import translation +from django.utils.translation import gettext_lazy as _ from pipeline.component_framework.component import Component from pipeline.core.flow.activity import StaticIntervalGenerator from pipeline.core.flow.io import BooleanItemSchema, StringItemSchema @@ -65,9 +65,7 @@ def inputs_format(self): name=_("是否强制晚于当前时间"), key="force_check", type="boolean", - schema=BooleanItemSchema( - description=_("用户输入日期格式时是否强制要求时间晚于当前时间,只对日期格式定时输入有效") - ), + schema=BooleanItemSchema(description=_("用户输入日期格式时是否强制要求时间晚于当前时间,只对日期格式定时输入有效")), ), ] @@ -82,12 +80,12 @@ def plugin_execute(self, data, parent_data): force_check = data.get_one_of_inputs("force_check", True) # todo 需要考虑是否要支持空间的时区配置 # 项目时区获取 - tz = timezone.pytz.timezone(settings.TIME_ZONE) + tz = zoneinfo.ZoneInfo(settings.TIME_ZONE) data.outputs.business_tz = tz now = datetime.datetime.now(tz=tz) if self.date_regex.match(str(timing)): - eta = tz.localize(datetime.datetime.strptime(timing, "%Y-%m-%d %H:%M:%S")) + eta = datetime.datetime.strptime(timing, "%Y-%m-%d %H:%M:%S").replace(tzinfo=tz) if force_check and now > eta: message = _("定时时间需晚于当前时间") data.set_outputs("ex_data", message) diff --git a/bkflow/pipeline_plugins/components/collections/uniform_api/v1_0_0.py b/bkflow/pipeline_plugins/components/collections/uniform_api/v1_0_0.py index c390709e67..88308f0c83 100644 --- a/bkflow/pipeline_plugins/components/collections/uniform_api/v1_0_0.py +++ b/bkflow/pipeline_plugins/components/collections/uniform_api/v1_0_0.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -18,7 +17,7 @@ to the current version of the project delivered to anyone in the future. """ from django.conf import settings -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.component_framework.component import Component from pipeline.core.flow.io import IntItemSchema, ObjectItemSchema diff --git a/bkflow/pipeline_plugins/components/collections/uniform_api/v2_0_0.py b/bkflow/pipeline_plugins/components/collections/uniform_api/v2_0_0.py index c12e5a4130..b174a20fec 100644 --- a/bkflow/pipeline_plugins/components/collections/uniform_api/v2_0_0.py +++ b/bkflow/pipeline_plugins/components/collections/uniform_api/v2_0_0.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -22,7 +21,7 @@ import jmespath from django.conf import settings -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.component_framework.component import Component from pipeline.core.flow.io import IntItemSchema, ObjectItemSchema from pydantic import BaseModel, ValidationError diff --git a/bkflow/pipeline_plugins/components/collections/value_assign/v1_0_0.py b/bkflow/pipeline_plugins/components/collections/value_assign/v1_0_0.py index fdcae282c5..931c7b4e8b 100644 --- a/bkflow/pipeline_plugins/components/collections/value_assign/v1_0_0.py +++ b/bkflow/pipeline_plugins/components/collections/value_assign/v1_0_0.py @@ -22,7 +22,7 @@ from bamboo_engine.eri import ContextValueType from django.conf import settings -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.component_framework.component import Component from pipeline.core.flow.io import ObjectItemSchema from pipeline.eri.runtime import BambooDjangoRuntime diff --git a/bkflow/pipeline_plugins/query/urls.py b/bkflow/pipeline_plugins/query/urls.py index 9cb2317a6a..dd0bbd7dae 100644 --- a/bkflow/pipeline_plugins/query/urls.py +++ b/bkflow/pipeline_plugins/query/urls.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -19,17 +18,17 @@ """ -from django.conf.urls import url +from django.urls import re_path from .select import variable_select_source_data_proxy from .uniform_api import uniform_api urlpatterns = [ - url(r"^uniform_api/list/(?P\d+)/$", uniform_api.get_space_uniform_api_list), - url( + re_path(r"^uniform_api/list/(?P\d+)/$", uniform_api.get_space_uniform_api_list), + re_path( r"^uniform_api/category_list/(?P\d+)/$", uniform_api.get_space_uniform_api_category_list, ), - url(r"^uniform_api/meta/(?P\d+)/$", uniform_api.get_space_uniform_api_meta), - url(r"^variable_select_source_data_proxy/$", variable_select_source_data_proxy), + re_path(r"^uniform_api/meta/(?P\d+)/$", uniform_api.get_space_uniform_api_meta), + re_path(r"^variable_select_source_data_proxy/$", variable_select_source_data_proxy), ] diff --git a/bkflow/pipeline_plugins/variables/collections/bk_user_selector.py b/bkflow/pipeline_plugins/variables/collections/bk_user_selector.py index 416bfb4458..406216b30c 100644 --- a/bkflow/pipeline_plugins/variables/collections/bk_user_selector.py +++ b/bkflow/pipeline_plugins/variables/collections/bk_user_selector.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -20,7 +19,7 @@ from typing import List -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.conf import settings from pipeline.core.data.var import LazyVariable diff --git a/bkflow/pipeline_plugins/variables/collections/datatable.py b/bkflow/pipeline_plugins/variables/collections/datatable.py index 733c3053de..4fccf6cfb4 100644 --- a/bkflow/pipeline_plugins/variables/collections/datatable.py +++ b/bkflow/pipeline_plugins/variables/collections/datatable.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -22,14 +21,14 @@ import logging from django.conf import settings -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.core.data.var import LazyVariable from pipeline.core.flow.io import StringItemSchema logger = logging.getLogger("root") -class DataTableValue(object): +class DataTableValue: def __init__(self, data): self._value = data item_values = {} @@ -52,7 +51,7 @@ class DataTable(LazyVariable): type = "meta" tag = "datatable.datatable" meta_tag = "datatable.datatable_meta" - form = "%svariables/%s.js" % (settings.STATIC_URL, code) + form = "{}variables/{}.js".format(settings.STATIC_URL, code) schema = StringItemSchema(description=_("表格变量")) desc = _( '引用表格变量某一列某一行的属性,如 ${KEY.columnA[0]} -> "test1"\n' diff --git a/bkflow/pipeline_plugins/variables/collections/datetime.py b/bkflow/pipeline_plugins/variables/collections/datetime.py index 88e3a9d618..78371c8891 100644 --- a/bkflow/pipeline_plugins/variables/collections/datetime.py +++ b/bkflow/pipeline_plugins/variables/collections/datetime.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -19,7 +18,7 @@ """ from typing import List -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.core.flow.io import StringItemSchema import settings @@ -36,12 +35,10 @@ class Datetime(CommonPlainVariable, SelfExplainVariable): name = _("日期时间") type = "general" tag = "datetime.datetime" - form = "%svariables/%s.js" % (settings.STATIC_URL, code) + form = "{}variables/{}.js".format(settings.STATIC_URL, code) schema = StringItemSchema(description=_("日期时间变量")) desc = _("输出格式: 2000-04-19 14:45:16") @classmethod def _self_explain(cls, **kwargs) -> List[FieldExplain]: - return [ - FieldExplain(key="${KEY}", type=Type.STRING, description="用户选择的时间,输出格式: 2000-04-19 14:45:16") - ] + return [FieldExplain(key="${KEY}", type=Type.STRING, description="用户选择的时间,输出格式: 2000-04-19 14:45:16")] diff --git a/bkflow/pipeline_plugins/variables/collections/datetime_range.py b/bkflow/pipeline_plugins/variables/collections/datetime_range.py index 0d73298789..42a52c22fa 100644 --- a/bkflow/pipeline_plugins/variables/collections/datetime_range.py +++ b/bkflow/pipeline_plugins/variables/collections/datetime_range.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -19,7 +18,7 @@ """ from typing import List -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.core.flow.io import StringItemSchema import settings @@ -36,7 +35,7 @@ class Datetime(CommonPlainVariable, SelfExplainVariable): name = _("日期时间范围") type = "general" tag = "datetime_range.datetime_range" - form = "%svariables/%s.js" % (settings.STATIC_URL, code) + form = "{}variables/{}.js".format(settings.STATIC_URL, code) schema = StringItemSchema(description=_("日期时间范围变量")) desc = _('输出格式: ["2023-01-1 00:00:00", "2023-01-01 23:59:59"]') diff --git a/bkflow/pipeline_plugins/variables/collections/input.py b/bkflow/pipeline_plugins/variables/collections/input.py index 967d6bd6ba..e5adb2c9c8 100644 --- a/bkflow/pipeline_plugins/variables/collections/input.py +++ b/bkflow/pipeline_plugins/variables/collections/input.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -20,7 +19,7 @@ from typing import List from django.conf import settings -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.core.flow.io import StringItemSchema from bkflow.pipeline_plugins.variables.base import ( @@ -36,7 +35,7 @@ class Input(CommonPlainVariable, SelfExplainVariable): name = _("输入框") type = "general" tag = "input.input" - form = "%svariables/%s.js" % (settings.STATIC_URL, code) + form = "{}variables/{}.js".format(settings.STATIC_URL, code) schema = StringItemSchema(description=_("输入框变量")) @classmethod diff --git a/bkflow/pipeline_plugins/variables/collections/int.py b/bkflow/pipeline_plugins/variables/collections/int.py index 5996e40362..b6d940e17f 100644 --- a/bkflow/pipeline_plugins/variables/collections/int.py +++ b/bkflow/pipeline_plugins/variables/collections/int.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -20,7 +19,7 @@ from typing import List from django.conf import settings -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.core.flow.io import IntItemSchema from bkflow.pipeline_plugins.variables.base import ( @@ -36,7 +35,7 @@ class Int(CommonPlainVariable, SelfExplainVariable): name = _("整数") type = "general" tag = "int.int" - form = "%svariables/%s.js" % (settings.STATIC_URL, code) + form = "{}variables/{}.js".format(settings.STATIC_URL, code) schema = IntItemSchema(description=_("整数变量")) @classmethod diff --git a/bkflow/pipeline_plugins/variables/collections/json_variable.py b/bkflow/pipeline_plugins/variables/collections/json_variable.py index 0098c4c9ab..6e2ee43311 100644 --- a/bkflow/pipeline_plugins/variables/collections/json_variable.py +++ b/bkflow/pipeline_plugins/variables/collections/json_variable.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -20,7 +19,7 @@ import json from django.conf import settings -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.core.data.var import LazyVariable from pipeline.core.flow.io import ObjectItemSchema @@ -30,7 +29,7 @@ class JsonVariable(LazyVariable): name = _("JSON 变量") type = "general" tag = "json_variable.json_variable" - form = "%svariables/%s.js" % (settings.STATIC_URL, code) + form = "{}variables/{}.js".format(settings.STATIC_URL, code) schema = ObjectItemSchema(description=_("内部结构不固定"), property_schemas={}) def get_value(self): diff --git a/bkflow/pipeline_plugins/variables/collections/select.py b/bkflow/pipeline_plugins/variables/collections/select.py index c83c7320fd..a226908306 100644 --- a/bkflow/pipeline_plugins/variables/collections/select.py +++ b/bkflow/pipeline_plugins/variables/collections/select.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -20,7 +19,7 @@ from typing import List from django.conf import settings -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.core.data.var import LazyVariable from pipeline.core.flow.io import StringItemSchema @@ -37,19 +36,13 @@ class Select(LazyVariable, SelfExplainVariable): type = "meta" tag = "select.select" meta_tag = "select.select_meta" - form = "%svariables/%s.js" % (settings.STATIC_URL, code) + form = "{}variables/{}.js".format(settings.STATIC_URL, code) schema = StringItemSchema(description=_("下拉框变量")) - desc = _( - "单选模式下输出选中的 value,多选模式下输出选中 value 以 ',' 拼接的字符串\n该变量默认不支持输入任意值,仅在子流程节点配置填参时支持输入任意值" - ) + desc = _("单选模式下输出选中的 value,多选模式下输出选中 value 以 ',' 拼接的字符串\n该变量默认不支持输入任意值,仅在子流程节点配置填参时支持输入任意值") @classmethod def _self_explain(cls, **kwargs) -> List[FieldExplain]: - return [ - FieldExplain( - key="${KEY}", type=Type.STRING, description="选中的 value,多选模式下输出选中 value 以 ',' 拼接的字符串" - ) - ] + return [FieldExplain(key="${KEY}", type=Type.STRING, description="选中的 value,多选模式下输出选中 value 以 ',' 拼接的字符串")] def get_value(self): # multiple select diff --git a/bkflow/pipeline_plugins/variables/collections/textarea.py b/bkflow/pipeline_plugins/variables/collections/textarea.py index 0e1db54039..9f20e3ae68 100644 --- a/bkflow/pipeline_plugins/variables/collections/textarea.py +++ b/bkflow/pipeline_plugins/variables/collections/textarea.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -20,7 +19,7 @@ from typing import List from django.conf import settings -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.core.flow.io import StringItemSchema from bkflow.pipeline_plugins.variables.base import ( @@ -36,7 +35,7 @@ class Textarea(CommonPlainVariable, SelfExplainVariable): name = _("文本框") type = "general" tag = "textarea.textarea" - form = "%svariables/%s.js" % (settings.STATIC_URL, code) + form = "{}variables/{}.js".format(settings.STATIC_URL, code) schema = StringItemSchema(description=_("文本框变量")) @classmethod diff --git a/bkflow/pipeline_web/core/abstract.py b/bkflow/pipeline_web/core/abstract.py index 59380354a9..d31f6e8725 100644 --- a/bkflow/pipeline_web/core/abstract.py +++ b/bkflow/pipeline_web/core/abstract.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -20,7 +19,7 @@ from django.db import models -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ class Node(models.Model): @@ -35,7 +34,7 @@ class Meta: ordering = ["-id"] -class NodeAttr(object): +class NodeAttr: node_in_template_attr = {} node_in_instance_attr = {} diff --git a/bkflow/pipeline_web/core/models.py b/bkflow/pipeline_web/core/models.py index 86a42a032b..c78a541fdd 100644 --- a/bkflow/pipeline_web/core/models.py +++ b/bkflow/pipeline_web/core/models.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -21,7 +20,7 @@ from django.db import models, transaction from django.utils.timezone import now -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from bkflow.pipeline_web.constants import PWE from bkflow.pipeline_web.core.abstract import Node diff --git a/bkflow/pipeline_web/core/signals/__init__.py b/bkflow/pipeline_web/core/signals/__init__.py index 438f7d53b2..ab4296fb48 100644 --- a/bkflow/pipeline_web/core/signals/__init__.py +++ b/bkflow/pipeline_web/core/signals/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -21,7 +20,7 @@ from django.dispatch import Signal -node_in_template_post_save = Signal(providing_args=["nodes_objs", "nodes_info"]) -node_in_template_delete = Signal(providing_args=["nodes_objs"]) +node_in_template_post_save = Signal() +node_in_template_delete = Signal() -node_in_instance_post_save = Signal(providing_args=["nodes_objs", "nodes_info"]) +node_in_instance_post_save = Signal() diff --git a/bkflow/pipeline_web/label/models.py b/bkflow/pipeline_web/label/models.py index 756d3cef2f..ae2b99171e 100644 --- a/bkflow/pipeline_web/label/models.py +++ b/bkflow/pipeline_web/label/models.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -20,7 +19,7 @@ from django.db import models -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from bkflow.pipeline_web.core.abstract import NodeAttr from bkflow.pipeline_web.core.models import NodeInInstanceAttr, NodeInTemplateAttr diff --git a/bkflow/pipeline_web/plugin_management/models.py b/bkflow/pipeline_web/plugin_management/models.py index 34ae410d28..cec09f055c 100644 --- a/bkflow/pipeline_web/plugin_management/models.py +++ b/bkflow/pipeline_web/plugin_management/models.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -20,7 +19,7 @@ from django.db import models -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ class DeprecatedPluginManager(models.Manager): diff --git a/bkflow/plugin/handlers.py b/bkflow/plugin/handlers.py index bbc996a87d..c726390163 100644 --- a/bkflow/plugin/handlers.py +++ b/bkflow/plugin/handlers.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -20,7 +19,7 @@ import concurrent.futures from django.conf import settings -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.component_framework.models import ComponentModel from rest_framework.exceptions import NotFound, PermissionDenied diff --git a/bkflow/plugin/serializers/comonent.py b/bkflow/plugin/serializers/comonent.py index 6891b80dae..ad48fb3c47 100644 --- a/bkflow/plugin/serializers/comonent.py +++ b/bkflow/plugin/serializers/comonent.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -23,7 +22,7 @@ from enum import Enum from django.conf import settings -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.component_framework.library import ComponentLibrary from pipeline.component_framework.models import ComponentModel from pipeline.exceptions import ComponentNotExistException @@ -96,7 +95,7 @@ def to_representation(self, instance): self.component_name = instance.name.split("-") except ComponentNotExistException: raise NotFound("Can not found {}({})".format(instance.code, instance.version)) - return super(ComponentModelSerializer, self).to_representation(instance) + return super().to_representation(instance) class ComponentModelListSerializer(ComponentModelSerializer): diff --git a/bkflow/plugin/urls.py b/bkflow/plugin/urls.py index eba6c17ba3..db14eb32b1 100644 --- a/bkflow/plugin/urls.py +++ b/bkflow/plugin/urls.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -18,7 +17,8 @@ to the current version of the project delivered to anyone in the future. """ -from django.conf.urls import include, url +from django.conf.urls import include +from django.urls import re_path from rest_framework.routers import DefaultRouter from bkflow.plugin.views.plugin import ComponentModelSetViewSet, UniformPluginViewSet @@ -28,5 +28,5 @@ router.register(r"uniform_plugin_query", UniformPluginViewSet, basename="uniform_plugin_query") urlpatterns = [ - url(r"^", include(router.urls)), + re_path(r"^", include(router.urls)), ] diff --git a/bkflow/space/configs.py b/bkflow/space/configs.py index 1faa8159d7..78837ed9c2 100644 --- a/bkflow/space/configs.py +++ b/bkflow/space/configs.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -21,7 +20,7 @@ from typing import Dict, Optional, Type import jsonschema -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pydantic import BaseModel, constr from pytimeparse import parse @@ -368,11 +367,9 @@ def validate(cls, value): raise ValidationError(f"[validate api_gateway_credential error]: {str(e)}") else: raise ValidationError( - ( - "[validate api_gateway_credential error]: " - "api_gateway_credential only support string or list of json: " - f"{cls.example}" - ) + "[validate api_gateway_credential error]: " + "api_gateway_credential only support string or list of json: " + f"{cls.example}" ) @classmethod diff --git a/bkflow/space/credential/dispatcher.py b/bkflow/space/credential/dispatcher.py index 470e88623a..d077146248 100644 --- a/bkflow/space/credential/dispatcher.py +++ b/bkflow/space/credential/dispatcher.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -17,7 +16,7 @@ to the current version of the project delivered to anyone in the future. """ -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from bkflow.space.credential.bkapp import BkAppCredential from bkflow.space.exceptions import CredentialTypeNotSupport diff --git a/bkflow/space/exceptions.py b/bkflow/space/exceptions.py index 859fd25c34..fbc852b032 100644 --- a/bkflow/space/exceptions.py +++ b/bkflow/space/exceptions.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -17,7 +16,7 @@ to the current version of the project delivered to anyone in the future. """ -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from bkflow.exceptions import BKFLOWException diff --git a/bkflow/space/models.py b/bkflow/space/models.py index b35b626f09..93ebd9dee4 100644 --- a/bkflow/space/models.py +++ b/bkflow/space/models.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -20,7 +19,7 @@ from enum import Enum from django.db import models, transaction -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ import env from bkflow.contrib.api.collections.task import TaskComponentClient diff --git a/bkflow/space/serializers.py b/bkflow/space/serializers.py index 1f207bae9b..1e8b60b4f1 100644 --- a/bkflow/space/serializers.py +++ b/bkflow/space/serializers.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -19,7 +18,7 @@ """ import logging -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from rest_framework import serializers from bkflow.exceptions import ValidationError @@ -81,7 +80,7 @@ class CredentialSerializer(serializers.ModelSerializer): update_at = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S") def to_representation(self, instance): - data = super(CredentialSerializer, self).to_representation(instance) + data = super().to_representation(instance) credential = CredentialDispatcher(credential_type=instance.type, data=instance.content) if credential: data["content"] = credential.display_value() diff --git a/bkflow/space/urls.py b/bkflow/space/urls.py index 296408cdd8..972b53c9a4 100644 --- a/bkflow/space/urls.py +++ b/bkflow/space/urls.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -18,7 +17,8 @@ to the current version of the project delivered to anyone in the future. """ -from django.conf.urls import include, url +from django.conf.urls import include +from django.urls import re_path from rest_framework.routers import DefaultRouter from bkflow.space.views import ( @@ -39,6 +39,6 @@ admin_router.register(r"credential_config", CredentialConfigAdminViewSet, basename="credential_config") urlpatterns = [ - url(r"^", include(router.urls)), - url(r"^admin/", include(admin_router.urls)), + re_path(r"^", include(router.urls)), + re_path(r"^admin/", include(admin_router.urls)), ] diff --git a/bkflow/task/models.py b/bkflow/task/models.py index 608ce3f40a..4424f7c646 100644 --- a/bkflow/task/models.py +++ b/bkflow/task/models.py @@ -22,7 +22,7 @@ from django.conf import settings from django.db import transaction from django.utils import timezone -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django_celery_beat.models import CrontabSchedule as DjangoCeleryBeatCrontabSchedule from django_celery_beat.models import PeriodicTask as DjangoCeleryBeatPeriodicTask from pipeline.contrib.periodic_task.djcelery.models import * # noqa diff --git a/bkflow/task/signals/signals.py b/bkflow/task/signals/signals.py index 90071d0211..b86ab42850 100644 --- a/bkflow/task/signals/signals.py +++ b/bkflow/task/signals/signals.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -19,6 +18,6 @@ """ from django.dispatch import Signal -taskflow_started = Signal(providing_args=["task_id"]) -taskflow_finished = Signal(providing_args=["task_id"]) -taskflow_revoked = Signal(providing_args=["task_id"]) +taskflow_started = Signal() +taskflow_finished = Signal() +taskflow_revoked = Signal() diff --git a/bkflow/task/urls.py b/bkflow/task/urls.py index 400e432955..98e831e244 100644 --- a/bkflow/task/urls.py +++ b/bkflow/task/urls.py @@ -16,8 +16,7 @@ to the current version of the project delivered to anyone in the future. """ -from django.conf.urls import url -from django.urls import include +from django.urls import include, re_path from rest_framework.routers import DefaultRouter from bkflow.task.views import PeriodicTaskViewSet, TaskInstanceViewSet @@ -28,5 +27,5 @@ urlpatterns = [ - url(r"", include(drf_router.urls)), + re_path(r"", include(drf_router.urls)), ] diff --git a/bkflow/task/utils.py b/bkflow/task/utils.py index 06b9f7e437..fcf4107131 100644 --- a/bkflow/task/utils.py +++ b/bkflow/task/utils.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -24,7 +23,7 @@ from bamboo_engine import states as bamboo_engine_states from django.conf import settings -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.core import constants as pipeline_constants from pipeline.engine.utils import calculate_elapsed_time from redis.client import Redis @@ -107,9 +106,7 @@ def parse_node_timeout_configs(pipeline_tree: dict) -> list: timeout_seconds = timeout_config.get("seconds") action = timeout_config.get("action") if not timeout_seconds or not isinstance(timeout_seconds, int): - message = _( - f"节点执行失败: 节点[ID: {act_id}]配置了非法的超时时间: {timeout_seconds}, 请修改配置后重试" - ) + message = _(f"节点执行失败: 节点[ID: {act_id}]配置了非法的超时时间: {timeout_seconds}, 请修改配置后重试") logger.error(message) # 对于不符合格式要求的情况,则不设置对应超时时间 continue diff --git a/bkflow/template/exceptions.py b/bkflow/template/exceptions.py index 6655f23ed5..fded583f12 100644 --- a/bkflow/template/exceptions.py +++ b/bkflow/template/exceptions.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -17,7 +16,7 @@ to the current version of the project delivered to anyone in the future. """ -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from bkflow.exceptions import BKFLOWException diff --git a/bkflow/template/models.py b/bkflow/template/models.py index d0fdd46ec4..94bd8acd6c 100644 --- a/bkflow/template/models.py +++ b/bkflow/template/models.py @@ -21,7 +21,7 @@ from copy import deepcopy from django.db import models, transaction -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.core.constants import PE from pipeline.parser.utils import replace_all_id diff --git a/bkflow/template/serializers.py b/bkflow/template/serializers.py index 6ea671dd10..59052690f8 100644 --- a/bkflow/template/serializers.py +++ b/bkflow/template/serializers.py @@ -17,7 +17,7 @@ import logging from django.db import transaction -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.validators import validate_pipeline_tree from rest_framework import serializers diff --git a/bkflow/template/serializers/template.py b/bkflow/template/serializers/template.py index 1832e6466e..35633dfdc7 100644 --- a/bkflow/template/serializers/template.py +++ b/bkflow/template/serializers/template.py @@ -22,7 +22,7 @@ from django.conf import settings from django.db import transaction from django.utils import timezone -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.validators import validate_pipeline_tree from rest_framework import serializers from webhook.signals import event_broadcast_signal diff --git a/bkflow/template/urls.py b/bkflow/template/urls.py index 1a32ddda32..f714354d4f 100644 --- a/bkflow/template/urls.py +++ b/bkflow/template/urls.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -18,15 +17,16 @@ to the current version of the project delivered to anyone in the future. """ -from django.conf.urls import include, url +from django.conf.urls import include +from django.urls import re_path from rest_framework.routers import DefaultRouter from bkflow.template.views.template import ( AdminTemplateViewSet, TemplateMockDataViewSet, TemplateMockSchemeViewSet, - TemplateViewSet, TemplateMockTaskViewSet, + TemplateViewSet, ) from bkflow.template.views.variable import VariableViewSet @@ -39,5 +39,5 @@ router.register(r"", TemplateViewSet, basename="template") urlpatterns = [ - url(r"^", include(router.urls)), + re_path(r"^", include(router.urls)), ] diff --git a/bkflow/template/views/template.py b/bkflow/template/views/template.py index 5804cd7886..65ff421585 100644 --- a/bkflow/template/views/template.py +++ b/bkflow/template/views/template.py @@ -19,7 +19,7 @@ import logging from django.db import transaction -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django_filters.rest_framework import DjangoFilterBackend, FilterSet from drf_yasg.utils import swagger_auto_schema from rest_framework import mixins diff --git a/bkflow/urls.py b/bkflow/urls.py index 16a813d4cd..424f34794a 100644 --- a/bkflow/urls.py +++ b/bkflow/urls.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -19,8 +18,7 @@ """ from blueapps.account.decorators import login_exempt from django.conf import settings -from django.conf.urls import url -from django.urls import include, path, register_converter +from django.urls import include, path, re_path, register_converter from django.views.decorators.csrf import csrf_exempt from pipeline.contrib.engine_admin import views as engine_admin_views from pipeline.contrib.engine_admin.urls import EngineConverter @@ -31,18 +29,18 @@ if settings.BKFLOW_MODULE.type == BKFLOWModuleType.interface: urlpatterns += [ - url(r"^", include("bkflow.interface.urls")), - url(r"^api/template/", include("bkflow.template.urls")), - url(r"^api/decision_table/", include("bkflow.decision_table.urls")), - url(r"^api/space/", include("bkflow.space.urls")), - url(r"^api/plugin/", include("bkflow.plugin.urls")), - url(r"^api/bk_plugin/", include("bkflow.bk_plugin.urls")), - url(r"^api/admin/", include("bkflow.admin.urls")), - url(r"^api/permission/", include("bkflow.permission.urls")), - url(r"^api/plugin_query/", include("bkflow.pipeline_plugins.query.urls")), - url(r"^api/plugin_service/", include("plugin_service.urls")), - url(r"^notice/", include("bk_notice_sdk.urls")), - url(r"^version_log/", include("version_log.urls", namespace="version_log")), + re_path(r"^", include("bkflow.interface.urls")), + re_path(r"^api/template/", include("bkflow.template.urls")), + re_path(r"^api/decision_table/", include("bkflow.decision_table.urls")), + re_path(r"^api/space/", include("bkflow.space.urls")), + re_path(r"^api/plugin/", include("bkflow.plugin.urls")), + re_path(r"^api/bk_plugin/", include("bkflow.bk_plugin.urls")), + re_path(r"^api/admin/", include("bkflow.admin.urls")), + re_path(r"^api/permission/", include("bkflow.permission.urls")), + re_path(r"^api/plugin_query/", include("bkflow.pipeline_plugins.query.urls")), + re_path(r"^api/plugin_service/", include("plugin_service.urls")), + re_path(r"^notice/", include("bk_notice_sdk.urls")), + re_path(r"^version_log/", include("version_log.urls", namespace="version_log")), ] elif settings.BKFLOW_MODULE.type == BKFLOWModuleType.engine: engine_admin_actions = [ @@ -65,5 +63,5 @@ for action in engine_admin_actions ] urlpatterns += [ - url(r"^task/", include("bkflow.task.urls")), + re_path(r"^task/", include("bkflow.task.urls")), ] + engine_admin_urlpatterns diff --git a/bkflow/utils/context.py b/bkflow/utils/context.py index 4e46939a49..948c29c54c 100644 --- a/bkflow/utils/context.py +++ b/bkflow/utils/context.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -18,10 +17,10 @@ to the current version of the project delivered to anyone in the future. """ import datetime +import zoneinfo from django.conf import settings -from django.utils import timezone -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ class TaskContext: @@ -40,7 +39,7 @@ def __init__(self, taskflow): self.task_id = taskflow.id self.task_name = taskflow.name self.is_mock = taskflow.create_method == "MOCK" - tz = timezone.pytz.timezone(settings.TIME_ZONE) + tz = zoneinfo.ZoneInfo(settings.TIME_ZONE) self.task_start_time = datetime.datetime.now(tz=tz).strftime("%Y-%m-%d %H:%M:%S") def context(self): @@ -48,7 +47,7 @@ def context(self): @classmethod def to_flat_key(cls, key): - return "${%s.%s}" % (cls.prefix, key) + return "${{{}.{}}}".format(cls.prefix, key) @classmethod def flat_details(cls): diff --git a/bkflow/utils/dates.py b/bkflow/utils/dates.py index e79355ce9d..82407eccbe 100644 --- a/bkflow/utils/dates.py +++ b/bkflow/utils/dates.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -23,7 +22,7 @@ from django.core.serializers.json import DjangoJSONEncoder from django.utils import timezone -from django.utils.encoding import force_text +from django.utils.encoding import force_str from django.utils.functional import Promise from django.utils.timezone import is_aware @@ -41,7 +40,7 @@ def format_datetime(dt: datetime.datetime, tz: datetime.tzinfo = None): def json_encoder_default(self, o): # See "Date Time String Format" in the ECMA-262 specification. if isinstance(o, Promise): - return force_text(o) + return force_str(o) elif isinstance(o, datetime.datetime): r = o.isoformat() if o.microsecond: diff --git a/bkflow/utils/handlers.py b/bkflow/utils/handlers.py index 22726836cd..4c9091a901 100644 --- a/bkflow/utils/handlers.py +++ b/bkflow/utils/handlers.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -22,7 +21,7 @@ import ujson as json from django.conf import settings -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ logger = logging.getLogger("root") diff --git a/bkflow/utils/mixins.py b/bkflow/utils/mixins.py index 846ff86d27..f57de040ee 100644 --- a/bkflow/utils/mixins.py +++ b/bkflow/utils/mixins.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -19,7 +18,7 @@ """ import logging -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django_filters.rest_framework import DjangoFilterBackend from rest_framework.filters import OrderingFilter, SearchFilter from rest_framework.pagination import LimitOffsetPagination @@ -67,7 +66,7 @@ def paginate_queryset(self, queryset, request, view=None): setattr(self, "limit", data_len) setattr(self, "offset", 0) return data - return super(BKFLOWNoMaxLimitPagination, self).paginate_queryset(queryset, request, view) + return super().paginate_queryset(queryset, request, view) class BKFlowOrderingFilter(OrderingFilter): @@ -81,9 +80,9 @@ class BKFLOWCommonMixin(GenericViewSet): def get_queryset(self): """支持不同acton调用不同的queryset""" self.queryset = getattr(self, f"{self.action}_queryset", self.queryset) - return super(BKFLOWCommonMixin, self).get_queryset() + return super().get_queryset() def get_serializer_class(self): """支持不同acton调用不同的serializer_class""" self.serializer_class = getattr(self, f"{self.action}_serializer_class", self.serializer_class) - return super(BKFLOWCommonMixin, self).get_serializer_class() + return super().get_serializer_class() diff --git a/bkflow/utils/models.py b/bkflow/utils/models.py index 1c0873c68a..59d4e5ed46 100644 --- a/bkflow/utils/models.py +++ b/bkflow/utils/models.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -21,7 +20,7 @@ import json from django.db import models -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pipeline.models import CompressJSONField, SnapshotManager from bkflow.utils.md5 import compute_pipeline_md5 @@ -44,7 +43,7 @@ def delete(self, using=None, keep_parents=False): self.save() def hard_delete(self): - super(CommonModel, self).delete() + super().delete() class CommonSnapshotManager(SnapshotManager): diff --git a/config/__init__.py b/config/__init__.py index 67ebbea194..936d663bd4 100644 --- a/config/__init__.py +++ b/config/__init__.py @@ -23,7 +23,7 @@ # This will make sure the app is always imported when # Django starts so that shared_task will use this app. from blueapps.core.celery import celery_app -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ __all__ = ["celery_app", "RUN_VER", "APP_CODE", "SECRET_KEY", "BK_URL", "BASE_DIR"] diff --git a/config/default.py b/config/default.py index 7600eb83ab..832fdfabaa 100644 --- a/config/default.py +++ b/config/default.py @@ -20,6 +20,7 @@ import base64 import datetime import json +import os from bamboo_engine.config import Settings as BambooSettings from blueapps.conf.default_settings import * # noqa @@ -238,7 +239,7 @@ IS_USE_CELERY = True # 前后端分离开发配置开关,设置为True时dev和stag环境会自动加载允许跨域的相关选项 -FRONTEND_BACKEND_SEPARATION = False +FRONTEND_BACKEND_SEPARATION = True # CELERY 并发数,默认为 2,可以通过环境变量或者 Procfile 设置 CELERYD_CONCURRENCY = env.BK_CELERYD_CONCURRENCY diff --git a/config/prod.py b/config/prod.py index 02429ff9b1..08f6cd8e2f 100644 --- a/config/prod.py +++ b/config/prod.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -37,18 +36,16 @@ # LOGGING = set_log_level(locals()) # 正式环境数据库可以在这里配置 -# DATABASES.update( -# { -# 'default': { -# 'ENGINE': 'django.db.backends.mysql', -# 'NAME': '', # 外部数据库名 -# 'USER': '', # 外部数据库用户 -# 'PASSWORD': '', # 外部数据库密码 -# 'HOST': '', # 外部数据库主机 -# 'PORT': '', # 外部数据库端口 -# }, -# } -# ) +DATABASES = { + "default": { + "ENGINE": "django.db.backends.mysql", + "NAME": os.getenv("BKAPP_FLOW_DB_NAME"), # 外部数据库名 + "USER": os.getenv("BKAPP_FLOW_DB_USER"), # 外部数据库用户 + "PASSWORD": os.getenv("BKAPP_FLOW_DB_PASSWORD"), # 外部数据库密码 + "HOST": os.getenv("BKAPP_FLOW_DB_HOST"), # 外部数据库主机 + "PORT": os.getenv("BKAPP_FLOW_DB_PORT"), # 外部数据库端口 + }, +} default.logging_addition_settings(LOGGING, environment="prod") BK_APIGW_STAGE_NAME = "prod" diff --git a/config/stag.py b/config/stag.py index 4a4cbdc086..9be4f9e821 100644 --- a/config/stag.py +++ b/config/stag.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -39,18 +38,16 @@ # LOGGING = set_log_level(locals()) # 预发布环境数据库可以在这里配置 -# DATABASES.update( -# { -# 'default': { -# 'ENGINE': 'django.db.backends.mysql', -# 'NAME': '', # 外部数据库名 -# 'USER': '', # 外部数据库用户 -# 'PASSWORD': '', # 外部数据库密码 -# 'HOST': '', # 外部数据库主机 -# 'PORT': '', # 外部数据库端口 -# }, -# } -# ) +DATABASES = { + "default": { + "ENGINE": "django.db.backends.mysql", + "NAME": os.getenv("BKAPP_FLOW_DB_NAME"), # 外部数据库名 + "USER": os.getenv("BKAPP_FLOW_DB_USER"), # 外部数据库用户 + "PASSWORD": os.getenv("BKAPP_FLOW_DB_PASSWORD"), # 外部数据库密码 + "HOST": os.getenv("BKAPP_FLOW_DB_HOST"), # 外部数据库主机 + "PORT": os.getenv("BKAPP_FLOW_DB_PORT"), # 外部数据库端口 + }, +} # 前后端开发模式下支持跨域配置 if FRONTEND_BACKEND_SEPARATION: diff --git a/plugin_service/README.md b/plugin_service/README.md index 50940eaba5..f31f78f8c7 100644 --- a/plugin_service/README.md +++ b/plugin_service/README.md @@ -22,7 +22,7 @@ INSTALLED_APPS += ( ``` python urlpatterns = [ ..., - url(r"^plugin_service/", include("plugin_service.urls")), + re_path(r"^plugin_service/", include("plugin_service.urls")), ..., ] ``` diff --git a/plugin_service/docs/openapi_config.md b/plugin_service/docs/openapi_config.md index 72abbd542d..6295c249e8 100644 --- a/plugin_service/docs/openapi_config.md +++ b/plugin_service/docs/openapi_config.md @@ -16,9 +16,9 @@ ) urlpatterns += [ - url(r"^swagger(?P\.json|\.yaml)$", schema_view.without_ui(cache_timeout=0), name="schema-json"), - url(r"^swagger/$", schema_view.with_ui("swagger", cache_timeout=0), name="schema-swagger-ui"), - url(r"^redoc/$", schema_view.with_ui("redoc", cache_timeout=0), name="schema-redoc"), + re_path(r"^swagger(?P\.json|\.yaml)$", schema_view.without_ui(cache_timeout=0), name="schema-json"), + re_path(r"^swagger/$", schema_view.with_ui("swagger", cache_timeout=0), name="schema-swagger-ui"), + re_path(r"^redoc/$", schema_view.with_ui("redoc", cache_timeout=0), name="schema-redoc"), ] ``` diff --git a/plugin_service/urls.py b/plugin_service/urls.py index 8e7f4bc5a9..3f35f09520 100644 --- a/plugin_service/urls.py +++ b/plugin_service/urls.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -19,17 +18,17 @@ """ -from django.conf.urls import url +from django.urls import re_path from . import api urlpatterns = [ - url(r"^list/$", api.get_plugin_list), - url(r"^detail_list/$", api.get_plugin_detail_list), - url(r"^tags/$", api.get_plugin_tags), - url(r"^meta/$", api.get_meta), - url(r"^detail/$", api.get_plugin_detail), - url(r"^logs/$", api.get_logs), - url(r"^app_detail/$", api.get_plugin_app_detail), - url(r"^data_api/(?P.+?)/(?P.+)$", api.get_plugin_api_data), + re_path(r"^list/$", api.get_plugin_list), + re_path(r"^detail_list/$", api.get_plugin_detail_list), + re_path(r"^tags/$", api.get_plugin_tags), + re_path(r"^meta/$", api.get_meta), + re_path(r"^detail/$", api.get_plugin_detail), + re_path(r"^logs/$", api.get_logs), + re_path(r"^app_detail/$", api.get_plugin_app_detail), + re_path(r"^data_api/(?P.+?)/(?P.+)$", api.get_plugin_api_data), ] diff --git a/requirements.txt b/requirements.txt index fc39a05235..f2864852b7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,77 +1,61 @@ # -*- coding: utf-8 -*- -# 工程预装模块 -# 需要额外的python包,可直接在文件后面添加 -# 请确保指定的包和版本号,可通过pip安装 +# Python 3.12 & Django 3.2 compatible requirements -# blueapps requirement -redis==4.1.4 -pymysql==1.1.1 -Django==3.2.25 -celery==5.2.3 -eventlet==0.33.3 -greenlet==1.1.3 -django-celery-beat==2.2.0 -django-celery-results==2.4.0 -django-cors-headers==3.7.0 -djangorestframework==3.12.4 -django-filter==2.4.0 -drf-yasg==1.20.0 -blueapps==4.15.8 -gunicorn==23.0.0 +# --- 蓝鲸依赖 (Django 3.2 配置) --- +blueapps[opentelemetry]==5.0.0rc6 +apigw-manager[cryptography]==1.1.7 -# jwt -pyCryptodome==3.19.1 -PyJWT==2.4.0 -cryptography==42.0.4 +# --- Django 生态 --- +Django==4.2.23 +djangorestframework==3.15.1 +django-filter==23.1 +django-cors-headers==4.3.0 +drf-yasg==1.21.7 -# PaaS 增强服务需要的依赖包,请不要修改,否则可能导增强服务不可用 -# for sentry -raven==6.10.0 +# --- Celery 生态 --- +celery==5.3.0 +django-celery-beat==2.8.0 +django-celery-results==2.5.1 +eventlet==0.39.1 +greenlet==3.0.3 # interface -jsonschema==2.5.1 -django-versionlog==1.6.0 -bk-notice-sdk==1.3.0 +jsonschema==4.17.0 +django-versionlog==1.8.1 +bk-notice-sdk==1.4.2 # engine service -boto3==1.26.133 -bamboo-pipeline==3.29.5 -pydantic==1.10.6 +boto3==1.34.129 +bamboo-pipeline==5.0.0rc0 +pydantic==1.10.17 django-extensions==3.2.1 # bkflow feel bkflow-feel==1.2.0 bkflow-dmn==0.2.0 -bkflow-django-webhook==1.2.2 +bkflow-django-webhook==2.0.0rc0 -# pytimeparse -pytimeparse == 1.1.8 -django-filter==2.4.0 +# --- 核心工具库 --- +gunicorn==23.0.0 +redis==4.6.0 +requests==2.32.4 +pymysql==1.1.1 +Werkzeug==3.0.6 -# opentelemetry -protobuf==3.19.4 -opentelemetry-api==1.11.1 -opentelemetry-sdk==1.11.1 -opentelemetry-exporter-otlp==1.11.1 -opentelemetry-exporter-jaeger==1.11.1 -opentelemetry-exporter-jaeger-proto-grpc==1.11.1 -opentelemetry-exporter-jaeger-thrift==1.11.1 -opentelemetry-instrumentation==0.30b1 -opentelemetry-instrumentation-celery==0.30b1 -opentelemetry-instrumentation-django==0.30b1 -opentelemetry-instrumentation-dbapi==0.30b1 -opentelemetry-instrumentation-redis==0.30b1 -opentelemetry-instrumentation-logging==0.30b1 -opentelemetry-instrumentation-requests==0.30b1 -prometheus-client==0.9.0 -django-prometheus==2.1.0 +# --- 加密与认证 --- +pyCryptodome==3.20.0 +PyJWT==2.8.0 +cryptography==45.0.1 -apigw-manager[cryptography]==1.1.7 -Werkzeug==1.0.1 -requests==2.28.2 -django-dbconn-retry==0.1.5 +# --- PaaS 增强服务 (Sentry) --- +# sentry-sdk[django]==2.0.1 +raven==6.10.0 + +# --- 其他三方库 --- jmespath==1.0.1 -pyinstrument==3.1.3 -tldextract==3.1.2 +pytimeparse==1.1.8 +tldextract==5.1.2 +pyinstrument==4.6.2 +pytz==2023.4 -mock==4.0.3 +django-dbconn-retry==0.1.9 \ No newline at end of file diff --git a/runtime.txt b/runtime.txt index 8985c704eb..12c138a41a 100644 --- a/runtime.txt +++ b/runtime.txt @@ -1 +1 @@ -python-3.9.12 \ No newline at end of file +python-3.12.11 \ No newline at end of file diff --git a/tests/plugins/components/collections/sleep_time_test/test_legacy.py b/tests/plugins/components/collections/sleep_time_test/test_legacy.py index bef17e3dab..24bb10542f 100644 --- a/tests/plugins/components/collections/sleep_time_test/test_legacy.py +++ b/tests/plugins/components/collections/sleep_time_test/test_legacy.py @@ -18,10 +18,10 @@ """ import datetime import time +import zoneinfo from django.conf import settings from django.test import TestCase -from django.utils import timezone from pipeline.component_framework.test import ( ComponentTestCase, ComponentTestMixin, @@ -48,7 +48,14 @@ def cases(self): "force_check": True, } VALID_SECONDS_INPUT = {"bk_timing": 10, "force_check": True} -BUSINESS_TIMEZONE = timezone.pytz.timezone(settings.TIME_ZONE) +BUSINESS_TIMEZONE = zoneinfo.ZoneInfo(settings.TIME_ZONE) + +# -------------------【Python 3.9+ 修改点】: 提前计算期望结果】------------------- +# 将字符串解析为 naive datetime 对象 +_NAIVE_DATETIME = datetime.datetime.strptime(VALID_DATETIME_INPUT["bk_timing"], "%Y-%m-%d %H:%M:%S") +# 使用 .replace() 附加时区信息,得到我们期望的 aware datetime 对象 +EXPECTED_AWARE_DATETIME = _NAIVE_DATETIME.replace(tzinfo=BUSINESS_TIMEZONE) +# ----------------------------------------------------------------- INVALID_SECONDS_TEST_CASE = ComponentTestCase( name="invalid seconds input test case", @@ -70,21 +77,11 @@ def cases(self): parent_data={}, execute_assertion=ExecuteAssertion( success=True, - outputs={ - "business_tz": BUSINESS_TIMEZONE, - "timing_time": BUSINESS_TIMEZONE.localize( - datetime.datetime.strptime(VALID_DATETIME_INPUT["bk_timing"], "%Y-%m-%d %H:%M:%S") - ), - }, + outputs={"business_tz": BUSINESS_TIMEZONE, "timing_time": EXPECTED_AWARE_DATETIME}, ), schedule_assertion=ScheduleAssertion( success=True, - outputs={ - "business_tz": BUSINESS_TIMEZONE, - "timing_time": BUSINESS_TIMEZONE.localize( - datetime.datetime.strptime(VALID_DATETIME_INPUT["bk_timing"], "%Y-%m-%d %H:%M:%S") - ), - }, + outputs={"business_tz": BUSINESS_TIMEZONE, "timing_time": EXPECTED_AWARE_DATETIME}, callback_data={}, ), ) diff --git a/urls.py b/urls.py index 65b48c762b..6635f19417 100644 --- a/urls.py +++ b/urls.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ TencentBlueKing is pleased to support the open source community by making 蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available. @@ -19,8 +18,8 @@ """ from django.conf import settings -from django.conf.urls import include, url from django.contrib import admin +from django.urls import include, re_path from django.views import static from drf_yasg import openapi from drf_yasg.views import get_schema_view @@ -29,22 +28,24 @@ from bkflow.utils.django_error_hanlder import page_not_found urlpatterns = [ - url(r"^bkflow_admin/", admin.site.urls), - url(r"^", include("bkflow.urls")), - url(r"^apigw/", include("bkflow.apigw.urls")), - url(r"^account/", include("blueapps.account.urls")), - url(r"^i18n/", include("django.conf.urls.i18n")), + re_path(r"^bkflow_admin/", admin.site.urls), + re_path(r"^", include("bkflow.urls")), + re_path(r"^apigw/", include("bkflow.apigw.urls")), + re_path(r"^account/", include("blueapps.account.urls")), + re_path(r"^i18n/", include("django.conf.urls.i18n")), ] if settings.IS_LOCAL: urlpatterns += [ # media - url(r"^media/(?P.*)$", static.serve, {"document_root": settings.MEDIA_ROOT}), - url("favicon.ico", static.serve, {"document_root": settings.STATIC_ROOT, "path": "core/images/bk_sops.png"}), + re_path(r"^media/(?P.*)$", static.serve, {"document_root": settings.MEDIA_ROOT}), + re_path( + "favicon.ico", static.serve, {"document_root": settings.STATIC_ROOT, "path": "core/images/bk_sops.png"} + ), ] if not settings.DEBUG: urlpatterns += [ - url(r"^static/(?P.*)$", static.serve, {"document_root": settings.STATIC_ROOT}), + re_path(r"^static/(?P.*)$", static.serve, {"document_root": settings.STATIC_ROOT}), ] handler404 = page_not_found @@ -62,7 +63,7 @@ if settings.ENVIRONMENT != "production" or settings.ENABLE_SWAGGER_UI: urlpatterns += [ - url(r"^swagger(?P\.json|\.yaml)$", schema_view.without_ui(cache_timeout=0), name="schema-json"), - url(r"^swagger/$", schema_view.with_ui("swagger", cache_timeout=0), name="schema-swagger-ui"), - url(r"^redoc/$", schema_view.with_ui("redoc", cache_timeout=0), name="schema-redoc"), + re_path(r"^swagger(?P\.json|\.yaml)$", schema_view.without_ui(cache_timeout=0), name="schema-json"), + re_path(r"^swagger/$", schema_view.with_ui("swagger", cache_timeout=0), name="schema-swagger-ui"), + re_path(r"^redoc/$", schema_view.with_ui("redoc", cache_timeout=0), name="schema-redoc"), ]