aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorPjotr Prins2017-05-31 07:12:28 +0000
committerPjotr Prins2017-05-31 07:12:28 +0000
commit755b9aaa31c73cc5fe8c1a75d74846f1d8594419 (patch)
tree72981d86a63942e2f2a85127089e6b015af6c07a /wqflask
parent9d4cb56608ca5de3495ede9149443e772a25d706 (diff)
downloadgenenetwork2-755b9aaa31c73cc5fe8c1a75d74846f1d8594419.tar.gz
JS module handling
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/utility/tools.py37
-rw-r--r--wqflask/wqflask/views.py6
2 files changed, 32 insertions, 11 deletions
diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py
index d46a84ba..c1c6fd36 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))
@@ -212,16 +230,19 @@ USE_REDIS = get_setting_bool('USE_REDIS')
USE_GN_SERVER = get_setting_bool('USE_GN_SERVER')
GENENETWORK_FILES = get_setting('GENENETWORK_FILES')
-GUIX_JS_PATH = get_setting('GUIX_JS_PATH')
-assert_dir(GUIX_JS_PATH)
-
-PYLMM_COMMAND = pylmm_command()
-GEMMA_COMMAND = gemma_command()
-PLINK_COMMAND = plink_command()
+JS_GUIX_PATH = get_setting('JS_GUIX_PATH')
+assert_dir(JS_GUIX_PATH)
+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
-TWITTER_POST_FETCHER_JS_PATH = GUIX_JS_PATH + "/Twitter-Post-Fetcher"
-assert_dir(TWITTER_POST_FETCHER_JS_PATH)
+# ---- 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
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 3882e60a..07151425 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,TWITTER_POST_FETCHER_JS_PATH
+from utility.tools import SQL_URI,TEMPDIR,USE_REDIS,USE_GN_SERVER,GN_SERVER_URL,GN_VERSION,JS_TWITTER_POST_FETCHER_PATH
from utility.helper_functions import get_species_groups
from base import webqtlFormData
@@ -147,8 +147,8 @@ def tmp_page(img_path):
img_base64 = bytesarray )
@app.route("/twitter/<path:filename>")
-def bd_files(filename):
- return send_from_directory(TWITTER_POST_FETCHER_JS_PATH, filename)
+def twitter(filename):
+ return send_from_directory(JS_TWITTER_POST_FETCHER_PATH, filename)
#@app.route("/data_sharing")
#def data_sharing_page():