summaryrefslogtreecommitdiff
path: root/python/fisx
diff options
context:
space:
mode:
authorPicca Frédéric-Emmanuel <picca@synchrotron-soleil.fr>2016-06-24 08:46:52 +0200
committerPicca Frédéric-Emmanuel <picca@synchrotron-soleil.fr>2016-06-24 08:46:52 +0200
commit5c1004928e0ebd1347a93ab23f2ab1b3cb62440a (patch)
tree2b1840cd2cd8bed5920bbb85c259d3f4aa0b6b29 /python/fisx
parentc14f2612e92457ddc12c5f254feccb87d189ccea (diff)
Imported Upstream version 1.0.8
Diffstat (limited to 'python/fisx')
-rw-r--r--python/fisx/DataDir.py32
1 files changed, 23 insertions, 9 deletions
diff --git a/python/fisx/DataDir.py b/python/fisx/DataDir.py
index a67f15d..16ee9a5 100644
--- a/python/fisx/DataDir.py
+++ b/python/fisx/DataDir.py
@@ -28,7 +28,7 @@
import os
# this will be filled by the setup
FISX_DATA_DIR = 'DATA_DIR_FROM_SETUP'
-# This is to be filled by the setup
+# this is to be filled by the setup
FISX_DOC_DIR = 'DOC_DIR_FROM_SETUP'
# what follows is only used in frozen versions
if not os.path.exists(FISX_DATA_DIR):
@@ -45,9 +45,9 @@ if not os.path.exists(FISX_DATA_DIR):
# this is used in build directory
if not os.path.exists(FISX_DATA_DIR):
- tmp_dir = os.path.dirname(__file__)
+ tmp_dir = os.path.dirname(os.path.abspath(__file__))
old_tmp_dir = tmp_dir + "dummy"
- basename = os.path.basename(FISX_DATA_DIR)
+ basename = "fisx_data"
FISX_DATA_DIR = os.path.join(tmp_dir, "fisx", basename)
while (len(FISX_DATA_DIR) > 14) and (tmp_dir != old_tmp_dir):
if os.path.exists(FISX_DATA_DIR):
@@ -57,7 +57,16 @@ if not os.path.exists(FISX_DATA_DIR):
FISX_DATA_DIR = os.path.join(tmp_dir, "fisx", basename)
if not os.path.exists(FISX_DATA_DIR):
- raise IOError('%s directory not found' % basename)
+ FISX_DATA_DIR = os.getenv("FISX_DATA_DIR")
+ if FISX_DATA_DIR is not None:
+ if not os.path.exists(FISX_DATA_DIR):
+ raise IOError('%s directory set from environent not found' % FISX_DATA_DIR)
+ else:
+ txt = "WARNING: Taking FISX_DATA_DIR from environement.\n"
+ txt += "Use it at your own risk."
+ print(txt)
+ else:
+ raise IOError('%s directory not found' % basename)
# do the same for the directory containing HTML files
if not os.path.exists(FISX_DOC_DIR):
@@ -71,13 +80,11 @@ if not os.path.exists(FISX_DOC_DIR):
old_tmp_dir = tmp_dir
tmp_dir = os.path.dirname(tmp_dir)
FISX_DOC_DIR = os.path.join(tmp_dir, basename)
-if not os.path.exists(FISX_DOC_DIR):
- raise IOError('%s directory not found' % basename)
if not os.path.exists(FISX_DOC_DIR):
- tmp_dir = os.path.dirname(__file__)
+ tmp_dir = os.path.dirname(os.path.abspath(__file__))
old_tmp_dir = tmp_dir + "dummy"
- basename = os.path.basename(FISX_DOC_DIR)
+ basename = "fisx_data"
FISX_DOC_DIR = os.path.join(tmp_dir,basename)
while (len(FISX_DOC_DIR) > 14) and (tmp_dir != old_tmp_dir):
if os.path.exists(FISX_DOC_DIR):
@@ -85,5 +92,12 @@ if not os.path.exists(FISX_DOC_DIR):
old_tmp_dir = tmp_dir
tmp_dir = os.path.dirname(tmp_dir)
FISX_DOC_DIR = os.path.join(tmp_dir, "fisx", basename)
+
if not os.path.exists(FISX_DOC_DIR):
- raise IOError('%s directory not found' % basename)
+ FISX_DOC_DIR = os.getenv("FISX_DOC_DIR")
+ if FISX_DOC_DIR is not None:
+ if not os.path.exists(FISX_DOC_DIR):
+ raise IOError('%s directory not found' % basename)
+ else:
+ # use the data dir as doc dir
+ FISX_DOC_DIR = FISX_DATA_DIR