aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility
diff options
context:
space:
mode:
authorLei Yan2017-06-26 19:40:09 +0000
committerLei Yan2017-06-26 19:40:09 +0000
commit10e3996ad0f1da29dd6f27ec3c10aa6d8660ed03 (patch)
tree59eba8bb4f99087854d6004648023b05e0a69b38 /wqflask/utility
parentafd2028e0ddab64e433eceb19e8cbd8d7149e080 (diff)
parente467c3f19824415d9e9a3fdd4073d44439c83cbf (diff)
downloadgenenetwork2-10e3996ad0f1da29dd6f27ec3c10aa6d8660ed03.tar.gz
Merge branch 'master' of github.com:genenetwork/genenetwork2
Diffstat (limited to 'wqflask/utility')
-rw-r--r--wqflask/utility/tools.py40
1 files changed, 31 insertions, 9 deletions
diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py
index c28c617a..393ff2df 100644
--- a/wqflask/utility/tools.py
+++ b/wqflask/utility/tools.py
@@ -13,6 +13,11 @@ logger = logging.getLogger(__name__ )
OVERRIDES = {}
+def app_set(command_id, value):
+ """Set application wide value"""
+ app.config.setdefault(command_id,value)
+ value
+
def get_setting(command_id,guess=None):
"""Resolve a setting from the environment or the global settings in
app.config, with valid_path is a function checking whether the
@@ -40,6 +45,7 @@ def get_setting(command_id,guess=None):
def value(command):
if command:
# sys.stderr.write("Found "+command+"\n")
+ app_set(command_id,command)
return command
else:
return None
@@ -89,6 +95,18 @@ def valid_path(dir):
return dir
return None
+def js_path(module=None):
+ """
+ Find the JS module in the two paths
+ """
+ try_gn = get_setting("JS_GN_PATH")+"/"+module
+ if valid_path(try_gn):
+ return try_gn
+ try_guix = get_setting("JS_GUIX_PATH")+"/"+module
+ if valid_path(try_guix):
+ return try_guix
+ raise "No JS path found for "+module+" (check JS_GN_PATH)"
+
def pylmm_command(guess=None):
return valid_bin(get_setting("PYLMM_COMMAND",guess))
@@ -205,21 +223,27 @@ 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')
-
-PYLMM_COMMAND = pylmm_command()
-GEMMA_COMMAND = gemma_command()
-GEMMA_RESULTS_PATH = get_setting('GEMMA_RESULTS_PATH')
-PLINK_COMMAND = plink_command()
+JS_GUIX_PATH = get_setting('JS_GUIX_PATH')
+# assert_dir(JS_GUIX_PATH) - don't enforce right now
+JS_GN_PATH = get_setting('JS_GN_PATH')
+# assert_dir(JS_GN_PATH)
+
+PYLMM_COMMAND = app_set("PYLMM_COMMAND",pylmm_command())
+GEMMA_COMMAND = app_set("GEMMA_COMMAND",gemma_command())
+PLINK_COMMAND = app_set("PLINK_COMMAND",plink_command())
TEMPDIR = tempdir() # defaults to UNIX TMPDIR
+# ---- Handle specific JS modules
+JS_TWITTER_POST_FETCHER_PATH = get_setting("JS_TWITTER_POST_FETCHER_PATH",js_path("Twitter-Post-Fetcher"))
+assert_dir(JS_TWITTER_POST_FETCHER_PATH)
+
from six import string_types
if os.environ.get('WQFLASK_OVERRIDES'):
@@ -234,5 +258,3 @@ if os.environ.get('WQFLASK_OVERRIDES'):
else:
OVERRIDES[k] = cmd
logger.debug(OVERRIDES)
-
-assert_dir(get_setting("TWITTER_POST_FETCHER_JS_PATH"))