From 634517f71ddb5ba70e0ac339612152f166b7aa9b Mon Sep 17 00:00:00 2001 From: waylon <1158341873@qq.com> Date: Mon, 23 Sep 2024 14:32:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9F=BA=E7=A1=80=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E8=B0=83=E6=95=B4=20--story=3D119806440?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 5 ++--- settings.py | 23 +++++++++++++---------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/requirements.txt b/requirements.txt index ff6bbfc0df..acd5115175 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ # Base Django==3.2.15 -PyMySQL==0.6.7 -mysqlclient==2.0.3 +pymysql==1.0.2 requests==2.25.1 httplib2==0.19.0 Mako==1.1.4 @@ -61,7 +60,7 @@ importlib-metadata==3.7.3 protobuf==3.19.4 # blueapps -blueapps[opentelemetry,bkcrypto]==4.8.0 +blueapps[opentelemetry,bkcrypto]==4.14.0 whitenoise==5.2.0 raven==6.5.0 python-json-logger==2.0.1 diff --git a/settings.py b/settings.py index 628d6203d9..b4df5117f6 100644 --- a/settings.py +++ b/settings.py @@ -17,24 +17,27 @@ import os +import pymysql + +pymysql.install_as_MySQLdb() + # V3判断环境的环境变量为BKPAAS_ENVIRONMENT -if 'BKPAAS_ENVIRONMENT' in os.environ: - ENVIRONMENT = os.getenv('BKPAAS_ENVIRONMENT', 'dev') +if "BKPAAS_ENVIRONMENT" in os.environ: + ENVIRONMENT = os.getenv("BKPAAS_ENVIRONMENT", "dev") # V2判断环境的环境变量为BK_ENV else: - PAAS_V2_ENVIRONMENT = os.environ.get('BK_ENV', 'development') + PAAS_V2_ENVIRONMENT = os.environ.get("BK_ENV", "development") ENVIRONMENT = { - 'development': 'dev', - 'testing': 'stag', - 'production': 'prod', + "development": "dev", + "testing": "stag", + "production": "prod", }.get(PAAS_V2_ENVIRONMENT) -DJANGO_CONF_MODULE = 'config.{env}'.format(env=ENVIRONMENT) +DJANGO_CONF_MODULE = "config.{env}".format(env=ENVIRONMENT) try: - _module = __import__(DJANGO_CONF_MODULE, globals(), locals(), ['*']) + _module = __import__(DJANGO_CONF_MODULE, globals(), locals(), ["*"]) except ImportError as e: - raise ImportError("Could not import config '%s' (Is it on sys.path?): %s" - % (DJANGO_CONF_MODULE, e)) + raise ImportError("Could not import config '%s' (Is it on sys.path?): %s" % (DJANGO_CONF_MODULE, e)) for _setting in dir(_module): if _setting == _setting.upper():