diff --git a/requirements.txt b/requirements.txt index ff6bbfc0d..acd511517 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 628d6203d..b4df5117f 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():