diff options
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/utility/tools.py | 14 | ||||
-rw-r--r-- | wqflask/wqflask/views.py | 3 |
2 files changed, 12 insertions, 5 deletions
diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py index 44bbb1b0..dc7bc33c 100644 --- a/wqflask/utility/tools.py +++ b/wqflask/utility/tools.py @@ -9,6 +9,7 @@ import os import sys from wqflask import app + def get_setting(command_id,guess=None): """Resolve a setting from the environment or the global settings in app.config, with get_valid_path is a function checking whether the @@ -33,7 +34,7 @@ def get_setting(command_id,guess=None): different settings.py file (or setting the environment). """ - def valid(command): + def value(command): if command: sys.stderr.write("Found value "+command+"\n") return command @@ -42,12 +43,12 @@ def get_setting(command_id,guess=None): # ---- Check whether environment exists sys.stderr.write("Looking for "+command_id+"\n") - command = valid(os.environ.get(command_id)) + command = value(os.environ.get(command_id)) if not command: # ---- Check whether setting exists in app - command = valid(app.config.get(command_id)) + command = value(app.config.get(command_id)) if not command: - command = valid(guess) + command = value(guess) if not command: raise Exception(command_id+' path unknown or faulty (update settings.py?). '+command_id+' should point to the path') return command @@ -76,3 +77,8 @@ def flat_files(subdir=None): if subdir: return valid_path(base+"/"+subdir) return valid_path(base) + +def tempdir(): + return valid_path(get_setting("TEMPDIR","/tmp")) + +TEMPDIR = tempdir() diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 3bf64a18..929da649 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -50,6 +50,7 @@ from wqflask.correlation import corr_scatter_plot from wqflask.wgcna import wgcna_analysis from utility import temp_data +from utility.tools import TEMPDIR from base import webqtlFormData from utility.benchmark import Bench @@ -423,7 +424,7 @@ def marker_regression_page(): print("img_path:", img_path) initial_start_vars = request.form print("initial_start_vars:", initial_start_vars) - imgfile = open('/home/zas1024/tmp/' + img_path, 'rb') + imgfile = open(TEMPDIR + '/' + img_path, 'rb') imgdata = imgfile.read() imgB64 = imgdata.encode("base64") bytesarray = array.array('B', imgB64) |