diff options
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/cfg/default_settings.py | 22 | ||||
-rw-r--r-- | wqflask/runserver.py | 14 | ||||
-rw-r--r-- | wqflask/utility/tools.py | 24 | ||||
-rw-r--r-- | wqflask/wqflask/database.py | 1 | ||||
-rw-r--r-- | wqflask/wqflask/user_manager.py | 5 |
5 files changed, 34 insertions, 32 deletions
diff --git a/wqflask/cfg/default_settings.py b/wqflask/cfg/default_settings.py index 88159321..5af61d5a 100644 --- a/wqflask/cfg/default_settings.py +++ b/wqflask/cfg/default_settings.py @@ -1,21 +1 @@ -LOGFILE = """/tmp/flask_gn_log""" - -#This is needed because Flask turns key errors into a -#400 bad request response with no exception/log -TRAP_BAD_REQUEST_ERRORS = True - -# http://pythonhosted.org/Flask-Security/configuration.html -SECURITY_CONFIRMABLE = True -SECURITY_TRACKABLE = True -SECURITY_REGISTERABLE = True -SECURITY_RECOVERABLE = True - -SECURITY_EMAIL_SENDER = "no-reply@genenetwork.org" - -SECURITY_POST_LOGIN_VIEW = "/thank_you" - -SQLALCHEMY_POOL_RECYCLE = 3600 - -SECURITY_PASSWORD_HASH = "bcrypt" -SESSION_TYPE = "filesystem" -SECRET_KEY = "secretkey" +# no longer in use diff --git a/wqflask/runserver.py b/wqflask/runserver.py index 4556056d..344826ce 100644 --- a/wqflask/runserver.py +++ b/wqflask/runserver.py @@ -24,7 +24,19 @@ import logging import utility.logger logger = utility.logger.getLogger(__name__ ) -logger.info(app.config) +BLUE = '\033[94m' +GREEN = '\033[92m' +BOLD = '\033[1m' +ENDC = '\033[0m' + +# We always output this information on startup +print "runserver.py: ****** The webserver has the following configuration ******" +keylist = app.config.keys() +keylist.sort() +for k in keylist: + print("%s %s%s%s%s" % (k,BLUE,BOLD,app.config[k],ENDC)) + +logger.info("GN2 is running. Visit %shttp://localhost:5003/%s" % (BLUE,ENDC)) from utility.tools import WEBSERVER_MODE diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py index 824ce330..1b31857e 100644 --- a/wqflask/utility/tools.py +++ b/wqflask/utility/tools.py @@ -43,16 +43,26 @@ def get_setting(command_id,guess=None): # ---- Check whether environment exists logger.debug("Looking for "+command_id+"\n") command = value(os.environ.get(command_id)) - if not command: + if command == None or command == "": # ---- Check whether setting exists in app command = value(app.config.get(command_id)) - if not command: + if command == None: command = value(guess) - if not command: - raise Exception(command_id+' setting unknown or faulty (update settings.py?).') + if command == None or command == "": + raise Exception(command_id+' setting unknown or faulty (update default_settings.py?).') logger.info("Set "+command_id+"="+str(command)) return command +def get_setting_bool(id): + v = get_setting(id) + if v not in [0,False,'False','FALSE',None]: + return True + return False + +def get_setting_int(id): + v = get_setting(id) + return int(v) + def valid_bin(bin): if os.path.islink(bin) or valid_file(bin): return bin @@ -136,9 +146,9 @@ def tempdir(): # Cached values WEBSERVER_MODE = get_setting('WEBSERVER_MODE') LOG_LEVEL = get_setting('LOG_LEVEL') -DEBUG_LOG_LEVEL = get_setting('DEBUG_LOG_LEVEL') -LOG_SQL = get_setting('LOG_SQL') in [True,'TRUE','True','true'] -USE_REDIS = get_setting('USE_REDIS') in [True,'TRUE','True','true'] +DEBUG_LOG_LEVEL = get_setting_int('DEBUG_LOG_LEVEL') +LOG_SQL = get_setting_bool('LOG_SQL') +USE_REDIS = get_setting_bool('USE_REDIS') PYLMM_COMMAND = pylmm_command() GEMMA_COMMAND = gemma_command() diff --git a/wqflask/wqflask/database.py b/wqflask/wqflask/database.py index f9c57d78..90612348 100644 --- a/wqflask/wqflask/database.py +++ b/wqflask/wqflask/database.py @@ -24,6 +24,5 @@ def init_db(): logger.debug("database.py: Creating all model metadata..") Base.metadata.create_all(bind=engine) logger.info("database.py: Done creating all model metadata...") - logger.info("Point your browser at http://localhost:5003/") init_db() diff --git a/wqflask/wqflask/user_manager.py b/wqflask/wqflask/user_manager.py index 557708e9..6c67cc87 100644 --- a/wqflask/wqflask/user_manager.py +++ b/wqflask/wqflask/user_manager.py @@ -46,6 +46,7 @@ from wqflask.database import db_session from wqflask import model from utility import Bunch, Struct, after +from utility.tools import LOG_SQL import logging from utility.logger import getLogger @@ -144,8 +145,8 @@ class UserSession(object): """Actual sqlalchemy record""" # Only look it up once if needed, then store it try: - logging.basicConfig() - logging.getLogger('sqlalchemy.pool').setLevel(logging.DEBUG) + if LOG_SQL: + logging.getLogger('sqlalchemy.pool').setLevel(logging.DEBUG) # Already did this before return self.db_object |