Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3.11版本升级 #1469

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-20.04
env:
OS: ubuntu-20.04
PYTHON: "3.6"
PYTHON: "3.11.10"
RUN_ENV: "open"
APP_CODE: "bk_itsm"
APP_ID: "bk_itsm"
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@master
with:
python-version: 3.6
python-version: 3.11.10
- name: Setup Mysql
run: |
sudo systemctl start mysql.service
Expand Down
12 changes: 7 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
default_stages: [commit]
default_stages: [pre-commit]
default_language_version:
python: python3.11.10
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.1.0
rev: v5.0.0
hooks:
- id: check-merge-conflict
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 24.10.0
hooks:
- id: black
language_version: python3.6
language_version: python3.11.10
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.1.0
hooks:
- id: flake8
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v2.2.0
rev: v9.19.0
hooks:
- id: commitlint
stages: [commit-msg]
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.3
2.8.1
2 changes: 1 addition & 1 deletion app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ author: 蓝鲸智云
category: 办公应用
introduction: 流程服务是蓝鲸推出的轻量级ITSM,通过可自定义设计的流程模块,覆盖IT服务中的不同管理活动或应用场景。帮助企业用户规范内部管理流程,提升沟通及管理效率。
introduction_en: bk_itsm is a lightweight ITSM created by Blueking. It covers different application scenarios in IT services through customizable workflows and help enterprise users to implement standardize IT workflow, improve communication and management efficiency.
version: 2.7.3
version: 2.8.1
language: python
is_use_celery: True
is_use_celery_with_gevent: False
Expand Down
9 changes: 6 additions & 3 deletions app_desc.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
spec_version: 2
app_version: "2.7.3"
app_version: "2.8.1"
app:
region: default
bk_app_code: bk_itsm
Expand Down Expand Up @@ -35,6 +35,9 @@ modules:
- key: GUNICORN_THREAD_NUM
value: 10
description: GunicornThread数量
- key: C_FORCE_ROOT
value: 1
description: celery5 fit
scripts:
pre_release_hook: "bash ./bin/pre-release"
processes:
Expand All @@ -47,11 +50,11 @@ modules:
plan: 4C1G5R
replicas: 1
pworker:
command: python manage.py celery worker -n prefork@%h -P threads -c 10 -l info --maxtasksperchild=100
command: python manage.py celery worker -n prefork@%h -P threads -c 10 -l info --max-tasks-per-child=100
plan: 4C2G5R
replicas: 5
gworker:
command: python manage.py celery worker -P gevent -n gevent@%h -c 4 -l info --maxtasksperchild=100
command: python manage.py celery worker -P gevent -n gevent@%h -c 4 -l info --max-tasks-per-child=100
plan: 4C2G5R
replicas: 5
svc_discovery:
Expand Down
20 changes: 8 additions & 12 deletions blueking/component/open/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,18 @@


def get_signature(method, path, app_secret, params=None, data=None):
"""generate signature
"""
"""generate signature"""
kwargs = {}
if params:
kwargs.update(params)
if data:
data = json.dumps(data) if isinstance(data, dict) else data
kwargs['data'] = data
kwargs = '&'.join([
'%s=%s' % (k, v)
for k, v in sorted(iter(kwargs.items()), key=lambda x: x[0])
])
orignal = '%s%s?%s' % (method, path, kwargs)
kwargs["data"] = data
kwargs = "&".join(
["%s=%s" % (k, v) for k, v in sorted(iter(kwargs.items()), key=lambda x: x[0])]
)
orignal = "%s%s?%s" % (method, path, kwargs)
signature = base64.b64encode(
hmac.new(
str(app_secret),
orignal,
hashlib.sha1).digest())
hmac.new(str(app_secret), orignal, hashlib.sha256).digest()
)
return signature
20 changes: 19 additions & 1 deletion config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
from blueapps.opentelemetry.utils import inject_logging_trace_info
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.db.backends.mysql.features import DatabaseFeatures
from django.utils.functional import cached_property


from config import (
APP_CODE,
Expand Down Expand Up @@ -376,7 +379,9 @@ def _(s):
if IS_USE_REDIS:
CACHE_BACKEND_TYPE = os.environ.get("CACHE_BACKEND_TYPE", "RedisCache")
REDIS_PORT = os.environ.get("BKAPP_REDIS_PORT", 6379)
REDIS_PASSWORD = os.environ.get("BKAPP_REDIS_PASSWORD", "") # 密码中不能包括敏感字符,例如":"
REDIS_PASSWORD = os.environ.get(
"BKAPP_REDIS_PASSWORD", ""
) # 密码中不能包括敏感字符,例如":"
REDIS_SERVICE_NAME = os.environ.get("BKAPP_REDIS_SERVICE_NAME", "mymaster")
REDIS_MODE = os.environ.get("BKAPP_REDIS_MODE", "single")
REDIS_DB = os.environ.get("BKAPP_REDIS_DB", 0)
Expand Down Expand Up @@ -983,3 +988,16 @@ def redirect_func(request):
"BKAPP_QW_WEB_HOOK_URL",
"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key={}",
)


class PatchFeatures:
@cached_property
def minimum_database_version(self):
if self.connection.mysql_is_mariadb:
return (10, 4)
else:
return (5, 7)


# 将补丁应用到 DatabaseFeatures 中
DatabaseFeatures.minimum_database_version = PatchFeatures.minimum_database_version
3 changes: 1 addition & 2 deletions django_signal_valve/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@
import zlib

from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

try:
import pickle as pickle
except Exception:
import pickle



class IOField(models.BinaryField):
def __init__(self, compress_level=6, *args, **kwargs):
super(IOField, self).__init__(*args, **kwargs)
Expand Down
4 changes: 2 additions & 2 deletions iam/contrib/django/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"""

from django.http.response import JsonResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _

from iam.contrib.http import HTTP_AUTH_FORBIDDEN_CODE

Expand All @@ -26,5 +26,5 @@ def __init__(self, exc, *args, **kwargs):
"data": None,
"permission": exc.perms_apply_data(),
}
kwargs['status'] = kwargs.get("status", 499)
kwargs["status"] = kwargs.get("status", 499)
super(IAMAuthFailedResponse, self).__init__(*args, **kwargs)
34 changes: 17 additions & 17 deletions itsm/api/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"""


from django.conf.urls import include, url
from django.urls import include, re_path


__author__ = "蓝鲸智云"
Expand All @@ -38,35 +38,35 @@

urlpatterns = [
# 流程管理模块
url(r"^workflow/", include("itsm.workflow.urls")),
re_path(r"^workflow/", include("itsm.workflow.urls")),
# 单据模块
url(r"^ticket/", include("itsm.ticket.urls")),
re_path(r"^ticket/", include("itsm.ticket.urls")),
# 任务模块
url(r"^task/", include("itsm.task.urls")),
re_path(r"^task/", include("itsm.task.urls")),
# 服务模块
url(r"^service/", include("itsm.service.urls")),
re_path(r"^service/", include("itsm.service.urls")),
# sla模块
url(r"^sla/", include("itsm.sla.urls")),
re_path(r"^sla/", include("itsm.sla.urls")),
# postman
url(r"^postman/", include("itsm.postman.urls")),
re_path(r"^postman/", include("itsm.postman.urls")),
# 角色模块
url(r"^role/", include("itsm.role.urls")),
re_path(r"^role/", include("itsm.role.urls")),
# iadmin
url(r"^iadmin/", include("itsm.iadmin.urls")),
re_path(r"^iadmin/", include("itsm.iadmin.urls")),
# 网关转发模块,目前主要用于转发esb侧的接口调用
url(r"^gateway/", include("itsm.gateway.urls")),
re_path(r"^gateway/", include("itsm.gateway.urls")),
# "杂种"模块,没有model,且不知道放哪里合适,就放到这个模块吧!
url(r"^misc/", include("itsm.misc.urls")),
re_path(r"^misc/", include("itsm.misc.urls")),
# 单据状态模块
url(r"^ticket_status/", include("itsm.ticket_status.urls")),
re_path(r"^ticket_status/", include("itsm.ticket_status.urls")),
# Trigger Module
url(r"^trigger/", include("itsm.trigger.urls")),
re_path(r"^trigger/", include("itsm.trigger.urls")),
# iam
url(r"^iam/", include("itsm.auth_iam.urls")),
re_path(r"^iam/", include("itsm.auth_iam.urls")),
# iam
url(r"^project/", include("itsm.project.urls")),
re_path(r"^project/", include("itsm.project.urls")),
# 人员选择器
url(r"^c/compapi/v2/usermanage/fs_list_users/$", get_batch_users),
re_path(r"^c/compapi/v2/usermanage/fs_list_users/$", get_batch_users),
# 蓝鲸插件服务
url(r"^plugin_service/", include("itsm.plugin_service.urls")),
re_path(r"^plugin_service/", include("itsm.plugin_service.urls")),
]
2 changes: 1 addition & 1 deletion itsm/auth_iam/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"""

from django.db import models
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _

from itsm.component.constants import LEN_NORMAL

Expand Down
11 changes: 8 additions & 3 deletions itsm/auth_iam/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"""

from django.conf import settings
from django.conf.urls import url
from django.urls import re_path
from rest_framework.routers import DefaultRouter

from iam import IAM
Expand All @@ -46,7 +46,12 @@
from itsm.auth_iam.views import ResourceViewSet, PermissionViewSet
from itsm.auth_iam.resources import ProjectResourceProvider

iam = IAM(settings.APP_CODE, settings.SECRET_KEY, settings.BK_IAM_INNER_HOST, settings.BK_PAAS_HOST)
iam = IAM(
settings.APP_CODE,
settings.SECRET_KEY,
settings.BK_IAM_INNER_HOST,
settings.BK_PAAS_HOST,
)

routers = DefaultRouter(trailing_slash=True)

Expand All @@ -70,5 +75,5 @@
dispatcher.register("task_template", TaskSchemaResourceProvider())
dispatcher.register("public_api", PublicApiResourceProvider())
urlpatterns = routers.urls + [
url(r'^resources/v1/$', dispatcher.as_view([login_exempt])),
re_path(r"^resources/v1/$", dispatcher.as_view([login_exempt])),
]
Loading