diff options
author | pjotrp | 2016-02-22 16:26:13 +0000 |
---|---|---|
committer | Pjotr Prins | 2016-04-20 08:46:51 +0000 |
commit | 94e3ac8e2fff5da72fd1c0358fdb6fdad9a7830c (patch) | |
tree | fa583980a004441c9f39ca94e1be47b1009c96cf /wqflask/utility | |
parent | 4b80bbfe261e8d0587a637b35416834e027f0999 (diff) | |
download | genenetwork2-94e3ac8e2fff5da72fd1c0358fdb6fdad9a7830c.tar.gz |
Introducing TEMPDIR
Diffstat (limited to 'wqflask/utility')
-rw-r--r-- | wqflask/utility/tools.py | 14 |
1 files changed, 10 insertions, 4 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() |