aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility
diff options
context:
space:
mode:
authorpjotrp2015-05-12 15:57:01 -0500
committerpjotrp2015-05-12 15:57:01 -0500
commit640e2f1485a055e6b060c5b67863bc986d079f70 (patch)
tree716c6e0f2f34ae2656e6412aaab0ca50ae28e06d /wqflask/utility
parentdcb0ef4e2b41d189d59d7d49c190ada02be45e0f (diff)
downloadgenenetwork2-640e2f1485a055e6b060c5b67863bc986d079f70.tar.gz
Move path search into tools.py
Diffstat (limited to 'wqflask/utility')
-rw-r--r--wqflask/utility/tools.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py
new file mode 100644
index 00000000..3c972557
--- /dev/null
+++ b/wqflask/utility/tools.py
@@ -0,0 +1,37 @@
+# Tools/paths finder resolves external paths from settings and/or environment
+# variables
+#
+# Currently supported:
+#
+# PYLMM_PATH finds the root of the git repository of the pylmm_gn2 tool
+
+import os
+
+def get_setting():
+ """
+ Resolve a setting from the environment or the global settings in app.config
+ """
+ pass
+
+def pylmm_command(default=None):
+ def get_valid_path(path):
+ if path and os.path.isfile(path+'/lmm.py'):
+ return path
+ else:
+ None
+
+ # ---- Check whether environment exists
+ path = get_valid_path(os.environ['PYLMM_PATH'])
+ # ---- Check whether setting exists
+ if not path:
+ path = get_valid_path(app.config.get('PYLMM_PATH'))
+ # ---- Check whether default exists
+ if not path:
+ path = get_valid_path(default)
+ home = get_valid_path(os.environ['HOME']+'/pylmm_gn2')
+ if not path:
+ path = get_valid_path(home)
+ if not path:
+ raise Exception('PYLMM_PATH '+home+' unknown or faulty (add PYLMM_PATH to settings.py)')
+ pylmm_command = 'python '+path+'/lmm.py'
+ return path,pylmm_command