From 67472b942129130ea77cb0a15e14ef42fd4d3b91 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Tue, 21 Jun 2016 09:55:11 +0000 Subject: Logger: switch for logging SQLALCHEMY --- etc/default_settings.py | 3 ++- wqflask/dbFunction/webqtlDatabaseFunction.py | 13 ++++--------- wqflask/utility/tools.py | 1 + wqflask/wqflask/user_manager.py | 4 ++-- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/etc/default_settings.py b/etc/default_settings.py index 4bb1b80c..b0060ed3 100644 --- a/etc/default_settings.py +++ b/etc/default_settings.py @@ -38,7 +38,8 @@ WEBSERVER_DEPLOY = None # Deployment specifics (nyi) LOG_LEVEL = 'WARNING' # Logger mode (DEBUG|INFO|WARNING|ERROR|CRITICAL) LOG_LEVEL_DEBUG = 1 # Debug log level (0-5) (nyi) -LOG_SQL = 'False' # Log SQL/backend calls +LOG_SQL = 'False' # Log SQL/backend and GN_SERVER calls +LOG_SQLALCHEMY = 'False' LOG_BENCH = True # Log bench marks USE_REDIS = True # REDIS caching (note that redis will be phased out) diff --git a/wqflask/dbFunction/webqtlDatabaseFunction.py b/wqflask/dbFunction/webqtlDatabaseFunction.py index b14c9312..846d5146 100644 --- a/wqflask/dbFunction/webqtlDatabaseFunction.py +++ b/wqflask/dbFunction/webqtlDatabaseFunction.py @@ -80,16 +80,11 @@ def retrieve_species(group): result = fetchone("select Species.Name from Species, InbredSet where InbredSet.Name = '%s' and InbredSet.SpeciesId = Species.Id" % (group)) return result[0] -########################################################################### -#input: cursor, groupName (string) -#output: mappingMethodId (int) info, value will be Null or else -#function: retrieve mappingMethodId info from InbredSet table -########################################################################### - def getMappingMethod(cursor=None, groupName=None): - cursor.execute("select MappingMethodId from InbredSet where Name= '%s'" % groupName) - mappingMethodId = cursor.fetchone()[0] - return mappingMethodId + if USE_GN_SERVER: + return gn_server("/cross/"+group+".json")["mapping_method_id"] + else: + return fetchone("select MappingMethodId from InbredSet where Name= '%s'" % groupName) ########################################################################### #input: cursor, inbredSetId (int), strainId (int) diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py index c1b635e0..0df471fc 100644 --- a/wqflask/utility/tools.py +++ b/wqflask/utility/tools.py @@ -171,6 +171,7 @@ WEBSERVER_MODE = get_setting('WEBSERVER_MODE') LOG_LEVEL = get_setting('LOG_LEVEL') LOG_LEVEL_DEBUG = get_setting_int('LOG_LEVEL_DEBUG') LOG_SQL = get_setting_bool('LOG_SQL') +LOG_SQLALCHEMY = get_setting_bool('LOG_SQLALCHEMY') LOG_BENCH = get_setting_bool('LOG_BENCH') USE_REDIS = get_setting_bool('USE_REDIS') USE_GN_SERVER = get_setting_bool('USE_GN_SERVER') diff --git a/wqflask/wqflask/user_manager.py b/wqflask/wqflask/user_manager.py index 6c67cc87..10fac06d 100644 --- a/wqflask/wqflask/user_manager.py +++ b/wqflask/wqflask/user_manager.py @@ -46,7 +46,7 @@ from wqflask.database import db_session from wqflask import model from utility import Bunch, Struct, after -from utility.tools import LOG_SQL +from utility.tools import LOG_SQL, LOG_SQLALCHEMY import logging from utility.logger import getLogger @@ -145,7 +145,7 @@ class UserSession(object): """Actual sqlalchemy record""" # Only look it up once if needed, then store it try: - if LOG_SQL: + if LOG_SQLALCHEMY: logging.getLogger('sqlalchemy.pool').setLevel(logging.DEBUG) # Already did this before -- cgit v1.2.3