From 8677d1b7bd5b32791c440bf0de2fc4c61c98299f Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sun, 21 May 2017 07:21:44 +0000 Subject: Merge from the diet branch. * refactored ./bin/genenetwork2 and /etc/default_settings - better detection of Guix - removed unused parameters, such as GEMMA_RESULT_PATH and TEMP_TRAITS - removing some default settings, such as PYLMM_COMMAND - rename some settings, such as SQL_URI and LOG_SQL_ALCHEMY - added GUIX_JS_PATH for JS modules * Added documentation on installing binary GN2 * Updated Twitter board to latest version in Guix - it had broken * Updated many tools in the latest Guix profile --- wqflask/base/webqtlConfig.py | 2 +- wqflask/maintenance/gen_select_dataset.py | 2 +- wqflask/utility/tools.py | 11 ++++----- wqflask/wqflask/database.py | 2 +- .../wqflask/marker_regression/marker_regression.py | 2 +- wqflask/wqflask/templates/base.html | 2 +- wqflask/wqflask/templates/error.html | 4 ++-- wqflask/wqflask/user_manager.py | 26 +++++++++++----------- wqflask/wqflask/views.py | 5 ++--- 9 files changed, 28 insertions(+), 28 deletions(-) (limited to 'wqflask') diff --git a/wqflask/base/webqtlConfig.py b/wqflask/base/webqtlConfig.py index 1e47e183..e5f10edf 100644 --- a/wqflask/base/webqtlConfig.py +++ b/wqflask/base/webqtlConfig.py @@ -65,7 +65,7 @@ ENSEMBLETRANSCRIPT_URL="http://useast.ensembl.org/Mus_musculus/Lucene/Details?sp # want to reach this base dir assert_writable_dir(TEMPDIR) -TMPDIR = mk_dir(TEMPDIR+'gn2') +TMPDIR = mk_dir(TEMPDIR+'/gn2/') assert_writable_dir(TMPDIR) CACHEDIR = mk_dir(TMPDIR+'/cache/') diff --git a/wqflask/maintenance/gen_select_dataset.py b/wqflask/maintenance/gen_select_dataset.py index e5726656..a5fd86e2 100644 --- a/wqflask/maintenance/gen_select_dataset.py +++ b/wqflask/maintenance/gen_select_dataset.py @@ -57,7 +57,7 @@ import urlparse from pprint import pformat as pf -#Engine = sa.create_engine(zach_settings.SQLALCHEMY_DATABASE_URI) +#Engine = sa.create_engine(zach_settings.SQL_URI) # build MySql database connection diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py index c28c617a..d46a84ba 100644 --- a/wqflask/utility/tools.py +++ b/wqflask/utility/tools.py @@ -205,21 +205,24 @@ SQL_URI = get_setting('SQL_URI') 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_SQL_ALCHEMY = get_setting_bool('LOG_SQL_ALCHEMY') LOG_BENCH = get_setting_bool('LOG_BENCH') LOG_FORMAT = "%(message)s" # not yet in use USE_REDIS = get_setting_bool('USE_REDIS') USE_GN_SERVER = get_setting_bool('USE_GN_SERVER') GENENETWORK_FILES = get_setting('GENENETWORK_FILES') -TEMP_TRAITS = get_setting('TEMP_TRAITS') +GUIX_JS_PATH = get_setting('GUIX_JS_PATH') +assert_dir(GUIX_JS_PATH) PYLMM_COMMAND = pylmm_command() GEMMA_COMMAND = gemma_command() -GEMMA_RESULTS_PATH = get_setting('GEMMA_RESULTS_PATH') PLINK_COMMAND = plink_command() TEMPDIR = tempdir() # defaults to UNIX TMPDIR +TWITTER_POST_FETCHER_JS_PATH = GUIX_JS_PATH + "/Twitter-Post-Fetcher" +assert_dir(TWITTER_POST_FETCHER_JS_PATH) + from six import string_types if os.environ.get('WQFLASK_OVERRIDES'): @@ -234,5 +237,3 @@ if os.environ.get('WQFLASK_OVERRIDES'): else: OVERRIDES[k] = cmd logger.debug(OVERRIDES) - -assert_dir(get_setting("TWITTER_POST_FETCHER_JS_PATH")) diff --git a/wqflask/wqflask/database.py b/wqflask/wqflask/database.py index 4df872ad..96c2c301 100644 --- a/wqflask/wqflask/database.py +++ b/wqflask/wqflask/database.py @@ -22,8 +22,8 @@ def init_db(): # they will be registered properly on the metadata. Otherwise # you will have to import them first before calling init_db() #import yourapplication.models + logger.info("Initializing database connection") import wqflask.model - logger.debug("Creating all model metadata") Base.metadata.create_all(bind=engine) logger.info("Done creating all model metadata") diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py index 87532445..8882c515 100644 --- a/wqflask/wqflask/marker_regression/marker_regression.py +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -37,7 +37,7 @@ from utility import temp_data from utility.benchmark import Bench from wqflask.marker_regression import gemma_mapping, rqtl_mapping, qtlreaper_mapping, plink_mapping -from utility.tools import locate, locate_ignore_error, PYLMM_COMMAND, GEMMA_COMMAND, GEMMA_RESULTS_PATH, PLINK_COMMAND, TEMPDIR +from utility.tools import locate, locate_ignore_error, PYLMM_COMMAND, GEMMA_COMMAND, PLINK_COMMAND, TEMPDIR from utility.external import shell from base.webqtlConfig import TMPDIR, GENERATED_TEXT_DIR diff --git a/wqflask/wqflask/templates/base.html b/wqflask/wqflask/templates/base.html index ec55ebeb..9ca3d63a 100644 --- a/wqflask/wqflask/templates/base.html +++ b/wqflask/wqflask/templates/base.html @@ -144,7 +144,7 @@

Development and source code on github with issue tracker and documentation. Join the mailing list and find us on IRC (#genenetwork channel). {% if version: %} -

GeneNetwork v{{ version }}

+

GeneNetwork {{ version }}

{% endif %} diff --git a/wqflask/wqflask/templates/error.html b/wqflask/wqflask/templates/error.html index c707a4fc..2f1e06fa 100644 --- a/wqflask/wqflask/templates/error.html +++ b/wqflask/wqflask/templates/error.html @@ -35,7 +35,7 @@

-    GeneNetwork v{{ version }} {{ stack[0] }}
+    GeneNetwork {{ version }} {{ stack[0] }}
     {{ message }} (error)
     {{ stack[-3] }}
     {{ stack[-2] }}
@@ -50,7 +50,7 @@
   Toggle full stack trace
   
-      GeneNetwork v{{ version }} {% for line in stack %} {{ line }}
+      GeneNetwork {{ version }} {% for line in stack %} {{ line }}
       {% endfor %}
     
diff --git a/wqflask/wqflask/user_manager.py b/wqflask/wqflask/user_manager.py index 1e831896..f7fcd2d0 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, LOG_SQLALCHEMY +from utility.tools import LOG_SQL, LOG_SQL_ALCHEMY import logging from utility.logger import getLogger @@ -69,7 +69,7 @@ class AnonUser(object): if self.cookie: logger.debug("already is cookie") self.anon_id = verify_cookie(self.cookie) - + else: logger.debug("creating new cookie") self.anon_id, self.cookie = create_signed_cookie() @@ -78,17 +78,17 @@ class AnonUser(object): @after.after_this_request def set_cookie(response): response.set_cookie(self.cookie_name, self.cookie) - + def add_collection(self, new_collection): collection_dict = dict(name = new_collection.name, created_timestamp = datetime.datetime.utcnow().strftime('%b %d %Y %I:%M%p'), changed_timestamp = datetime.datetime.utcnow().strftime('%b %d %Y %I:%M%p'), num_members = new_collection.num_members, members = new_collection.get_members()) - + Redis.set(self.key, json.dumps(collection_dict)) Redis.expire(self.key, 60 * 60 * 24 * 5) - + def delete_collection(self, collection_name): existing_collections = self.get_collections() updated_collections = [] @@ -106,7 +106,7 @@ class AnonUser(object): updated_collections.append(this_collection) Redis.set(self.key, json.dumps(updated_collections)) - + def get_collections(self): json_collections = Redis.get(self.key) if json_collections == None or json_collections == "None": @@ -117,7 +117,7 @@ class AnonUser(object): collection['created_timestamp'] = datetime.datetime.strptime(collection['created_timestamp'], '%b %d %Y %I:%M%p') collection['changed_timestamp'] = datetime.datetime.strptime(collection['changed_timestamp'], '%b %d %Y %I:%M%p') return collections - + def import_traits_to_user(self): collections_list = json.loads(Redis.get(self.key)) for collection in collections_list: @@ -131,7 +131,7 @@ class AnonUser(object): uc.members = json.dumps(collection['members']) db_session.add(uc) db_session.commit() - + def display_num_collections(self): """ Returns the number of collections or a blank string if there are zero. @@ -217,7 +217,7 @@ class UserSession(object): """Actual sqlalchemy record""" # Only look it up once if needed, then store it try: - if LOG_SQLALCHEMY: + if LOG_SQL_ALCHEMY: logging.getLogger('sqlalchemy.pool').setLevel(logging.DEBUG) # Already did this before @@ -237,7 +237,7 @@ class UserSession(object): def before_request(): g.user_session = UserSession() g.cookie_session = AnonUser() - + class UsersManager(object): def __init__(self): self.users = model.User.query.all() @@ -541,9 +541,9 @@ class LoginUser(object): import_col = "true" else: import_col = "false" - - #g.cookie_session.import_traits_to_user() - + + #g.cookie_session.import_traits_to_user() + return self.actual_login(user, import_collections=import_col) else: diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 39f4a686..3882e60a 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -53,7 +53,7 @@ from wqflask.ctl import ctl_analysis #from wqflask.trait_submission import submit_trait from utility import temp_data -from utility.tools import SQL_URI,TEMPDIR,USE_REDIS,USE_GN_SERVER,GN_SERVER_URL,GN_VERSION +from utility.tools import SQL_URI,TEMPDIR,USE_REDIS,USE_GN_SERVER,GN_SERVER_URL,GN_VERSION,TWITTER_POST_FETCHER_JS_PATH from utility.helper_functions import get_species_groups from base import webqtlFormData @@ -148,8 +148,7 @@ def tmp_page(img_path): @app.route("/twitter/") def bd_files(filename): - bd_path = app.config['TWITTER_POST_FETCHER_JS_PATH'] - return send_from_directory(bd_path, filename) + return send_from_directory(TWITTER_POST_FETCHER_JS_PATH, filename) #@app.route("/data_sharing") #def data_sharing_page(): -- cgit v1.2.3