diff options
Diffstat (limited to 'wqflask/utility')
-rw-r--r-- | wqflask/utility/helper_functions.py | 20 | ||||
-rw-r--r-- | wqflask/utility/logger.py | 2 | ||||
-rw-r--r-- | wqflask/utility/tools.py | 26 |
3 files changed, 46 insertions, 2 deletions
diff --git a/wqflask/utility/helper_functions.py b/wqflask/utility/helper_functions.py index 377f6b26..cf16879f 100644 --- a/wqflask/utility/helper_functions.py +++ b/wqflask/utility/helper_functions.py @@ -5,6 +5,9 @@ from base import data_set from base.species import TheSpecies from wqflask import user_manager + +from flask import Flask, g + import logging logger = logging.getLogger(__name__ ) @@ -41,3 +44,20 @@ def get_trait_db_obs(self, trait_db_list): name=trait_name, cellid=None) self.trait_list.append((trait_ob, dataset_ob)) + +def get_species_groups(): + + species_query = "SELECT SpeciesId, MenuName FROM Species" + species_ids_and_names = g.db.execute(species_query).fetchall() + + species_and_groups = [] + for species_id, species_name in species_ids_and_names: + this_species_groups = {} + this_species_groups['species'] = species_name + groups_query = "SELECT InbredSetName FROM InbredSet WHERE SpeciesId = %s" % (species_id) + groups = [group[0] for group in g.db.execute(groups_query).fetchall()] + + this_species_groups['groups'] = groups + species_and_groups.append(this_species_groups) + + return species_and_groups diff --git a/wqflask/utility/logger.py b/wqflask/utility/logger.py index bacb0aa4..128706df 100644 --- a/wqflask/utility/logger.py +++ b/wqflask/utility/logger.py @@ -72,7 +72,7 @@ LOG_LEVEL_DEBUG (NYI). def warning(self,*args): """Call logging.warning for multiple args""" self.collect(self.logger.warning,*args) - self.logger.warning(self.collect(*args)) + # self.logger.warning(self.collect(*args)) def error(self,*args): """Call logging.error for multiple args""" diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py index 23d6fb62..82ef136f 100644 --- a/wqflask/utility/tools.py +++ b/wqflask/utility/tools.py @@ -113,6 +113,21 @@ def assert_dir(dir): raise Exception("ERROR: can not find directory "+dir) return dir +def assert_writable_dir(dir): + try: + fn = dir + "/test.txt" + fh = open( fn, 'w' ) + fh.write("I am writing this text to the file\n") + fh.close() + os.remove(fn) + except IOError: + raise Exception('Unable to write test.txt to directory ' + dir) + return dir + +def assert_file(fn): + if not valid_file(fn): + raise Exception('Unable to find file '+fn) + return fn def mk_dir(dir): if not valid_path(dir): @@ -187,6 +202,7 @@ def show_settings(): # Cached values +GN_VERSION = get_setting('GN_VERSION') HOME = get_setting('HOME') WEBSERVER_MODE = get_setting('WEBSERVER_MODE') GN_SERVER_URL = get_setting('GN_SERVER_URL') @@ -201,11 +217,13 @@ 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') PYLMM_COMMAND = pylmm_command() GEMMA_COMMAND = gemma_command() +GEMMA_RESULTS_PATH = get_setting('GEMMA_RESULTS_PATH') PLINK_COMMAND = plink_command() -TEMPDIR = tempdir() +TEMPDIR = tempdir() # defaults to UNIX TMPDIR from six import string_types @@ -221,3 +239,9 @@ if os.environ.get('WQFLASK_OVERRIDES'): else: OVERRIDES[k] = cmd logger.debug(OVERRIDES) + +assert_dir(get_setting("JS_BIODALLIANCE")) +assert_file(get_setting("JS_BIODALLIANCE")+"/build/dalliance-all.js") +assert_file(get_setting("JS_BIODALLIANCE")+"/build/worker-all.js") +assert_dir(get_setting("JS_TWITTER_POST_FETCHER")) +assert_file(get_setting("JS_TWITTER_POST_FETCHER")+"/js/twitterFetcher_min.js") |