about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xbin/genenetwork210
-rw-r--r--wqflask/base/webqtlConfig.py22
-rw-r--r--wqflask/utility/tools.py12
3 files changed, 33 insertions, 11 deletions
diff --git a/bin/genenetwork2 b/bin/genenetwork2
index d7d1c325..b2de4c95 100755
--- a/bin/genenetwork2
+++ b/bin/genenetwork2
@@ -79,13 +79,13 @@ fi
 # We may change this one:
 export PYTHONPATH=$GN2_BASE_DIR/wqflask:$PYTHONPATH
 
-# TEMPDIR defaults to /tmp if nothing else
-if [ -z $TEMPDIR ]; then
-    TEMPDIR="/tmp"
+# Our UNIX TMPDIR defaults to /tmp - change this on a shared server
+if [ -z $TMPDIR ]; then
+    TMPDIR="/tmp"
 fi
 
 set|grep $GN2_PROFILE
-set|grep TEMPDIR
+set|grep TMPDIR
 
 # Now handle command parameter -c
 if [ "$1" = '-c' ] ; then
@@ -98,7 +98,7 @@ if [ "$1" = '-c' ] ; then
 fi
 
 echo "Starting the redis server:"
-echo -n "dir $TEMPDIR
+echo -n "dir $TMPDIR
 dbfilename gn2.rdb
 " | redis-server - &
 
diff --git a/wqflask/base/webqtlConfig.py b/wqflask/base/webqtlConfig.py
index 6bbabdec..e5f10edf 100644
--- a/wqflask/base/webqtlConfig.py
+++ b/wqflask/base/webqtlConfig.py
@@ -8,7 +8,7 @@
 #
 #########################################
 
-from utility.tools import valid_path, mk_dir, assert_dir, flat_files, TEMPDIR
+from utility.tools import valid_path, mk_dir, assert_dir, assert_writable_dir, flat_files, TEMPDIR
 
 #Debug Level
 #1 for debug, mod python will reload import each time
@@ -60,24 +60,36 @@ ENSEMBLETRANSCRIPT_URL="http://useast.ensembl.org/Mus_musculus/Lucene/Details?sp
 #   HTMLPATH is replaced by GENODIR
 #   IMGDIR is replaced by GENERATED_IMAGE_DIR
 
-# Temporary storage (note that this TMPDIR is not the same directory
-# as the UNIX TMPDIR)
+# Temporary storage (note that this TMPDIR can be set as an
+# environment variable - use utility.tools.TEMPDIR when you
+# want to reach this base dir
+assert_writable_dir(TEMPDIR)
+
 TMPDIR               = mk_dir(TEMPDIR+'/gn2/')
+assert_writable_dir(TMPDIR)
+
 CACHEDIR             = mk_dir(TMPDIR+'/cache/')
 # We can no longer write into the git tree:
 GENERATED_IMAGE_DIR  = mk_dir(TMPDIR+'/generated/')
 GENERATED_TEXT_DIR   = mk_dir(TMPDIR+'/generated_text/')
 
+# Make sure we have permissions to access these
+assert_writable_dir(CACHEDIR)
+assert_writable_dir(GENERATED_IMAGE_DIR)
+assert_writable_dir(GENERATED_TEXT_DIR)
+
 # Flat file directories
 GENODIR              = flat_files('genotype')+'/'
+assert_dir(GENODIR)
+
+# JSON genotypes are OBSOLETE
 JSON_GENODIR         = flat_files('genotype/json')+'/'
 if not valid_path(JSON_GENODIR):
     # fall back on old location (move the dir, FIXME)
     JSON_GENODIR = flat_files('json')
-assert_dir(GENODIR)
 
+# Are we using the following...?
 PORTADDR = "http://50.16.251.170"
-
 INFOPAGEHREF = '/dbdoc/%s.html'
 CGIDIR = '/webqtl/' #XZ: The variable name 'CGIDIR' should be changed to 'PYTHONDIR'
 SCRIPTFILE = 'main.py'
diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py
index 23d6fb62..5105ba42 100644
--- a/wqflask/utility/tools.py
+++ b/wqflask/utility/tools.py
@@ -113,6 +113,16 @@ def assert_dir(dir):
         raise Exception("ERROR: can not find directory "+dir)
     return dir
 
+def assert_writable_dir(dir):
+    try:
+        fn = dir + "/test.txt"
+        fh = open( fn, 'w' )
+        fh.write("I am writing this text to the file\n")
+        fh.close()
+        os.remove(fn)
+    except IOError:
+        raise Exception('Unable to write to directory ' + dir )
+    return dir
 
 def mk_dir(dir):
     if not valid_path(dir):
@@ -205,7 +215,7 @@ GENENETWORK_FILES  = get_setting('GENENETWORK_FILES')
 PYLMM_COMMAND      = pylmm_command()
 GEMMA_COMMAND      = gemma_command()
 PLINK_COMMAND      = plink_command()
-TEMPDIR            = tempdir()
+TEMPDIR            = tempdir() # defaults to UNIX TMPDIR
 
 from six import string_types