Commit b78df395 authored by Caillat Michel's avatar Caillat Michel
Browse files

Serious improvements

parent 13bbdcee
This diff is collapsed.
......@@ -89,7 +89,7 @@ class DataManagerImpl :
self.__logger.debug("__checkPresence : entering")
result = {"status": True, "message" : '', "result": None}
if relFITSFilePath in self.__dataBlocks:
self.__dataBlocks[relFITSFilePath].setTimestamp()
self.__dataBlocks[relFITSFilePath].setLastAccess()
else:
result = {"status": False, "message": f'FITS file "{relFITSFilePath}" is not present in memory. Call "setData" first'}
self.__logger.debug("__checkPresence : exiting")
......@@ -153,16 +153,15 @@ class DataManagerImpl :
#
def setData(self, relFITSFilePath):
self.__logger.debug("setData : entering")
result = None
if relFITSFilePath in self.__dataBlocks :
self.__logger.debug("File already opened: %s" % relFITSFilePath)
result = {"status": True, "message": "", "result":json.dumps(dict(self.__dataBlocks[relFITSFilePath].header()))}
result = self.__checkPresence(relFITSFilePath)
if result["status"]:
result = self.__dataBlocks[relFITSFilePath].getHeader()
else :
db = DataBlock(self.__logger)
result = db.setData(relFITSFilePath)
if (result["status"]):
self.__dataBlocks[relFITSFilePath]=db
self.__logger.debug(f"About to return {result}")
self.__logger.debug("setData : Exiting")
return result
......@@ -170,22 +169,18 @@ class DataManagerImpl :
# General getters
#
#
# Return the collection of defined DataBlock as a dictionary where keys are the relFITSFilePath
#
def getDataBlocks(self):
return self.__dataBlocks
#===========================================================================
# Getters on a DataBlock identified by its relFITSFilePath ( i.e. the dictionary keys in __dataBlocks )
#
def getDimensions(self, relFITSFilePath, sessionID):
def getDimensions(self, relFITSFilePath):
self.__logger.debug( "getDimensions : entering");
result = self.__checkPresence(relFITSFilePath)
if result["status"]:
result = self.__dataBlocks[relFITSFilePath].getDimensions()
self.__logger.debug( "getDimensions : exiting");
return {"status": True, "message": "", "result": result}
return result
def getSlice(self, sliceNumb, step, relFITSFilePath):
self.__logger.debug("getSlice : entering")
......@@ -208,7 +203,6 @@ class DataManagerImpl :
result = self.__checkPresence(relFITSFilePath)
if result["status"]:
result = self.__dataBlocks[relFITSFilePath].getAverageSpectrum(startY, endY, startX, endX)
self.__logger.debug(f"** {result}")
self.__logger.debug("getAverageSpectrum : exiting")
return result
......@@ -218,8 +212,8 @@ class DataManagerImpl :
result = self.__checkPresence(relFITSFilePath)
if result["status"]:
result = self.__dataBlocks[relFITSFilePath].getHeader()
self.__logger.debug("getHeader : exiting")
self.__logger.debug("About to return %r" % result)
self.__logger.debug("getHeader : exiting")
return result
def RADECRangeInDegrees( self, relFITSFilePath):
......@@ -344,7 +338,10 @@ class DataManagerImpl :
#
def getDataBlockInfos(self, reverse=True):
self.__logger.debug("getDataBlockInfos : entering")
result = [self.__dataBlocks[k].getDataBlockInfos() for k in self.__dataBlocks]
infoNames = DataBlock.getDataBlockInfoNames()
result = [infoNames]
for k in self.__dataBlocks:
result.append(self.__dataBlocks[k].getDataBlockInfos(infoNames))
self.__logger.debug("getDataBlockInfos : exiting")
return {"status": True, "message": "", "result": result}
......
......@@ -312,7 +312,6 @@ def getAverageSpectrum():
retFITS = getBoolValue(request.GET['retFITS'])
response.content_type = "application/json; charset=utf-8"
result = json.dumps(dm.getAverageSpectrum(relFITSFilePath, startY, endY, startX, endX, retFITS))
logger.debug(f"* {result}")
logger.debug("getAverageSpectrum - wrapper : exiting" )
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