diff options
author | Pjotr Prins | 2016-04-20 08:46:23 +0000 |
---|---|---|
committer | Pjotr Prins | 2016-04-20 08:46:23 +0000 |
commit | 4b80bbfe261e8d0587a637b35416834e027f0999 (patch) | |
tree | a67fa988cad9f8c0a3e77b49a3fc6db34b56e40e /wqflask/utility | |
parent | af7d0bca229f3ebaa80a16d1ce3a2bf1a8abd5df (diff) | |
download | genenetwork2-4b80bbfe261e8d0587a637b35416834e027f0999.tar.gz |
[PATCH 024/100] Sanitizing file handling
Diffstat (limited to 'wqflask/utility')
-rw-r--r-- | wqflask/utility/tools.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py index c3c9b292..44bbb1b0 100644 --- a/wqflask/utility/tools.py +++ b/wqflask/utility/tools.py @@ -52,17 +52,27 @@ def get_setting(command_id,guess=None): raise Exception(command_id+' path unknown or faulty (update settings.py?). '+command_id+' should point to the path') return command +def valid_bin(bin): + if os.path.islink(bin) or os.path.isfile(bin): + return bin + return None + +def valid_path(dir): + if os.path.isdir(dir): + return dir + return None + def pylmm_command(guess=None): - return get_setting("PYLMM_RUN",guess) + return valid_bin(get_setting("PYLMM_RUN",guess)) def gemma_command(guess=None): - return get_setting("GEMMA_RUN",guess) + return valid_bin(get_setting("GEMMA_RUN",guess)) def plink_command(guess=None): - return get_setting("PLINK_RUN",guess) + return valid_bin(get_setting("PLINK_RUN",guess)) def flat_files(subdir=None): base = get_setting("GENENETWORK_FILES") if subdir: - return base+"/"+subdir - return base + return valid_path(base+"/"+subdir) + return valid_path(base) |