From 6976d183d288f5647cefdd98188fb40e8f422319 Mon Sep 17 00:00:00 2001 From: pycook Date: Fri, 1 Jan 2016 10:22:44 +0800 Subject: [PATCH] delete settings.py --- .gitignore | 1 + config-sample.cfg | 15 +++++++-------- lib/spec_query_sql.py | 3 +++ lib/utils.py | 10 +++++----- settings.py | 7 ------- 5 files changed, 16 insertions(+), 20 deletions(-) create mode 100644 lib/spec_query_sql.py delete mode 100644 settings.py diff --git a/.gitignore b/.gitignore index 57532b8..daa87a1 100755 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ lib/special lib/audit* templates/*audit* codeLin* +lib/spec_* diff --git a/config-sample.cfg b/config-sample.cfg index 88177f4..83f4077 100644 --- a/config-sample.cfg +++ b/config-sample.cfg @@ -19,13 +19,18 @@ CACHE_REDIS_PORT = 6379 CACHE_KEY_PREFIX = "CMDB-API" CACHE_DEFAULT_TIMEOUT = 3000 + # # CI cache -REDIS_HOST = "127.0.0.1" -REDIS_PORT = 6379 REDIS_DB = 0 REDIS_MAX_CONN = 30 +# # queue +CELERY_RESULT_BACKEND = "redis://127.0.0.1//" +BROKER_URL = 'redis://127.0.0.1//' +BROKER_VHOST = '/' + + # # i18n ACCEPT_LANGUAGES = ['en', 'zh'] BABEL_DEFAULT_LOCALE = 'zh' @@ -48,12 +53,6 @@ MAIL_PASSWORD = '' DEFAULT_MAIL_SENDER = '' -# # queue -CELERY_RESULT_BACKEND = "redis://127.0.0.1//" -BROKER_URL = 'redis://127.0.0.1//' -BROKER_VHOST = '/' - - # # pagination PER_PAGE_COUNT_RANGE = (10, 25, 50, 100) DEFAULT_PAGE_COUNT = 25 diff --git a/lib/spec_query_sql.py b/lib/spec_query_sql.py new file mode 100644 index 0000000..8cc488f --- /dev/null +++ b/lib/spec_query_sql.py @@ -0,0 +1,3 @@ +# -*- coding:utf-8 -*- + +__author__ = 'pycook' diff --git a/lib/utils.py b/lib/utils.py index 2a31655..c8bf58f 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -4,17 +4,17 @@ import redis from flask import current_app -import settings class RedisHandler(object): def __init__(self): + config = current_app.config try: pool = redis.ConnectionPool( - max_connections=settings.REDIS_MAX_CONN, - host=settings.REDIS_HOST, - port=settings.REDIS_PORT, - db=settings.REDIS_DB) + max_connections=config.get("REDIS_MAX_CONN"), + host=config.get("CACHE_REDIS_HOST"), + port=config.get("CACHE_REDIS_PORT"), + db=config.get("REDIS_DB")) self.r = redis.Redis(connection_pool=pool) except Exception as e: print e diff --git a/settings.py b/settings.py deleted file mode 100644 index 9819a83..0000000 --- a/settings.py +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding:utf-8 -*- - -## CI cache -REDIS_HOST = "127.0.0.1" -REDIS_PORT = 6379 -REDIS_DB = 0 -REDIS_MAX_CONN = 30