Commit 00f50d85 authored by Caillat Michel's avatar Caillat Michel
Browse files

FITS toplevel dir is now found in env var YAFITS_FITSDIR and is capable of...

FITS toplevel dir is now found in env var YAFITS_FITSDIR and is capable of processing symbolic links to directories
parent 7ad552fb
...@@ -15,8 +15,9 @@ from datetime import datetime ...@@ -15,8 +15,9 @@ from datetime import datetime
from DataBlock import DataBlock from DataBlock import DataBlock
DataRoot = "dataroot" FITSFilePrefix = os.getenv("YAFITS_FITSDIR")
FITSFilePrefix = DataRoot + '/FITS/'
DataRoot = "/home/partemix/dataroot"
PNGFilePrefix = DataRoot + '/PNG/' PNGFilePrefix = DataRoot + '/PNG/'
OBJFilePrefix = DataRoot + '/OBJ/' OBJFilePrefix = DataRoot + '/OBJ/'
ApiDocPrefix = DataRoot + '/apidoc/' ApiDocPrefix = DataRoot + '/apidoc/'
...@@ -62,14 +63,21 @@ class DataManagerImpl : ...@@ -62,14 +63,21 @@ class DataManagerImpl :
try : try :
absFITSFilePrefix = FITSFilePrefix + relKey absFITSFilePrefix = FITSFilePrefix + relKey
entries = (os.listdir(absFITSFilePrefix)) entries = (os.listdir(absFITSFilePrefix))
self.__logger.debug("type of entries %s" % (type(entries))) self.__logger.debug("%r" % entries)
sortedEntries = entries.sort() sortedEntries = entries.sort()
children = [] children = []
for entry in entries: for entry in entries:
p = absFITSFilePrefix + '/' + entry p = absFITSFilePrefix + '/' + entry
condition = os.path.isfile(p) and p.endswith(".fits") condition = (os.path.isfile(p) and p.endswith(".fits"))
condition = condition or (os.path.islink(p) and os.path.isdir(os.readlink(p))) if not condition :
condition = condition or (os.path.isdir(p)) self.__logger.debug("%s link %r" % (p, os.path.islink(p)))
if os.path.islink(p):
target = os.path.realpath(p)
self.__logger.debug("%s is dir %r" %(target, os.path.isdir(target)))
condition = os.path.islink(p) # and os.path.isdir(target)
else :
condition = (os.path.isdir(p))
if not condition : if not condition :
continue continue
elif entry in ["log", "NOFITS", "IGNORE"]: elif entry in ["log", "NOFITS", "IGNORE"]:
...@@ -77,7 +85,7 @@ class DataManagerImpl : ...@@ -77,7 +85,7 @@ class DataManagerImpl :
else: else:
d = dict() d = dict()
d["key"] = relKey + '/' + entry d["key"] = relKey + '/' + entry
d["folder"] = not os.path.isfile(p) d["folder"] = not os.path.isfile(p)
d["lazy"] = d["folder"] d["lazy"] = d["folder"]
if entry.endswith(".fits") : if entry.endswith(".fits") :
size = DataBlock.convert_size(os.path.getsize(p)) size = DataBlock.convert_size(os.path.getsize(p))
...@@ -89,6 +97,7 @@ class DataManagerImpl : ...@@ -89,6 +97,7 @@ class DataManagerImpl :
except Exception as e : except Exception as e :
result = {"status": False, "message": "Problem while looking for entries under '%s'. Error message was '%s'" % ( relKey, e)} result = {"status": False, "message": "Problem while looking for entries under '%s'. Error message was '%s'" % ( relKey, e)}
self.__logger.debug("%r" % result) self.__logger.debug("%r" % result)
self.__logger.debug("%r" % result)
self.__logger.debug("__getEntries_0: exiting") self.__logger.debug("__getEntries_0: exiting")
return result return result
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment