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

Introduced **kwargs in the parameter list of some methods

parent 0f014e0b
......@@ -117,7 +117,8 @@ class DataBlock:
return DataBlock.__default_palette_name
@classmethod
def getDefaultVMName
def getDefaultVMName(cls):
return DataBlock.__default_video_mode_name
@classmethod
def convert_size(cls, sizeInBytes):
......@@ -754,15 +755,12 @@ class DataBlock:
self.__logger.debug("getAverage: exiting")
return {"status": True, "message": "", "result": result.tolist()}
def getOneSliceAsPNG (self, sliceIndex, transformation_name=DataBlock.__default_transformation_name, palette_name=DataBlock.__default_palette_name, \
video_mode_name=DataBlock.__default_video_mode_name):
def getOneSliceAsPNG (self, sliceIndex, ittName=__default_transformation_name, lutName=__default_palette_name, vmName=__default_video_mode_name):
self.__logger.debug("getOneSliceAsPNG: entering.")
self.__logger.debug("Video mode name = %s" % video_mode_name)
self.__logger.debug("sliceIndex = %r" % (sliceIndex))
relPNGFileDir = ('.').join(self.__relFITSFilePath.split('.')[:-1])
absPNGFileDir = DataBlock.getPNGFilePrefix()+"/"+relPNGFileDir
transformation_name = self.__getForcedTransformationName(transformation_name)
ittName = self.__getForcedTransformationName(ittName)
status = None
sliceData = None
......@@ -783,7 +781,7 @@ class DataBlock:
elif len(shape) == 4:
sliceData = data[0, sliceIndex,:,:]
relPNGFilePath = ("%s/%d.%s.%s.%s.png" % (relPNGFileDir, sliceIndex, transformation_name, palette_name, video_mode_name))
relPNGFilePath = ("%s/%d.%s.%s.%s.png" % (relPNGFileDir, sliceIndex, ittName, lutName, vmName))
absPNGFilePath = DataBlock.getPNGFilePrefix() + "/" + relPNGFilePath
#if not os.path.exists(absPNGFilePath):
......@@ -802,7 +800,7 @@ class DataBlock:
self.__logger.debug("... in cache directory is %s" % (self.__PNGDir))
try:
squaredSliceData = self.__squareSliceData( sliceData)
data_steps = self.__convertOneSlice2PNG_0(absPNGFilePath, squaredSliceData, transformation_name, palette_name, video_mode_name)
data_steps = self.__convertOneSlice2PNG_0(absPNGFilePath, squaredSliceData, ittName, lutName, vmName)
h = self.__header
if "CDELT1" in h and "CDELT2" in h:
......@@ -835,16 +833,16 @@ class DataBlock:
return {"status": True, "message": "", "result": result}
def getSummedSliceRangeAsPNG( self, sliceIndex0, sliceIndex1, transformation_name, palette_name, video_mode_name):
def getSummedSliceRangeAsPNG( self, sliceIndex0, sliceIndex1, ittName=__default_transformation_name, lutName=__default_palette_name, vmName=__default_video_mode_name):
self.__logger.debug("getSummedSliceRangeAsPNG: entering.")
self.__logger.debug("sliceIndex0=%r, sliceIndex1=%r"%(sliceIndex0, sliceIndex1))
relPNGFileDir = ('.').join(self.__relFITSFilePath.split('.')[:-1])
absPNGFileDir = DataBlock.getPNGFilePrefix()+"/"+relPNGFileDir
transformation_name = self.__getForcedTransformationName(transformation_name)
ittName = self.__getForcedTransformationName(ittName)
relPNGFilePath = ("%s/%d-%d.%s.%s.%s.png" % (relPNGFileDir, sliceIndex0, sliceIndex1, transformation_name, palette_name, video_mode_name))
relPNGFilePath = ("%s/%d-%d.%s.%s.%s.png" % (relPNGFileDir, sliceIndex0, sliceIndex1, ittName, lutName, vmName))
absPNGFilePath = DataBlock.getPNGFilePrefix() + "/" + relPNGFilePath
summedSliceRangeData = self.__getAverage_0(1, sliceIndex0, sliceIndex1)
......@@ -867,7 +865,7 @@ class DataBlock:
try:
squaredData = self.__squareSliceData(summedSliceRangeData)
data_steps = self.__convertSummedSliceRange2PNG(sliceIndex0, sliceIndex1, squaredData, transformation_name, palette_name, video_mode_name)
data_steps = self.__convertSummedSliceRange2PNG(sliceIndex0, sliceIndex1, squaredData, ittName, lutName, vmName)
h = self.__header
if "CDELT1" in h and "CDELT2" in h:
x = {"BITPIX": h["BITPIX"],
......
......@@ -280,21 +280,21 @@ class DataManagerImpl :
self.__logger.debug("getAverage : exiting")
return result
def getOneSliceAsPNG (self, sliceIndex, relFITSFilePath, transformation_name=None, palette_name=None, video_mode_name=None):
def getOneSliceAsPNG (self, sliceIndex, relFITSFilePath, **kwargs):
self.__logger.debug("getOneSliceAsPNG : entering.")
self.__logger.debug("sliceIndex = %r, relFITSFilePath = %r" % (sliceIndex, relFITSFilePath))
result = self.__checkPresence(relFITSFilePath)
if result["status"]:
result = self.__dataBlocks[relFITSFilePath].getOneSliceAsPNG(sliceIndex, transformation_name, palette_name, video_mode_name)
result = self.__dataBlocks[relFITSFilePath].getOneSliceAsPNG(sliceIndex, **kwargs)
self.__logger.debug("getOneSliceAsPNG : exiting.")
return result
def getSummedSliceRangeAsPNG( self, sliceIndex0, sliceIndex1, relFITSFilePath, transformation_name=__default_transformation_name, palette_name=__default_palette_name, video_mode_name=__default_video_mode_name):
def getSummedSliceRangeAsPNG( self, sliceIndex0, sliceIndex1, relFITSFilePath, **kwargs):
self.__logger.debug("getSummedSliceRangeAsPNG : entering.")
self.__logger.debug("sliceIndex0=%r, sliceIndex1=%r"%(sliceIndex0, sliceIndex1))
result = self.__checkPresence(relFITSFilePath)
if result["status"]:
result = self.__dataBlocks[relFITSFilePath].getSummedSliceRangeAsPNG(sliceIndex0, sliceIndex1, transformation_name, palette_name, video_mode_name)
result = self.__dataBlocks[relFITSFilePath].getSummedSliceRangeAsPNG(sliceIndex0, sliceIndex1, **kwargs)
self.__logger.debug("getSummedSliceRangeAsPNG : exiting.")
return result
......
......@@ -431,11 +431,11 @@ def getOneSliceAsPNG():
relFITSFilePath = rebuildFilename(body['relFITSFilePath'])
sliceIndex = getIntValue(body['sliceIndex'])
ittName = 'ittName' in body ? body['ittName'] : None
lutName = 'lutName' in body ? body['lutName'] : None
vmName = 'vmName' in body ? body['vmName'] : None
sessionID = 'sessionID' in body ? body['sessionID'] : 0
ret = dm.getOneSliceAsPNG(sliceIndex, relFITSFilePath, ittName,lutName, vmName)
kwargs = {}
for x in ['ittName', 'lutName', 'vmName']:
if x in body :
kwargs[x]=body[x]
ret = dm.getOneSliceAsPNG(sliceIndex, relFITSFilePath, **kwargs)
except Exception as e:
exc_type, exc_value, exc_traceback = sys.exc_info()
traceback.print_exc()
......@@ -464,11 +464,12 @@ def getSummedSliceRangeAsPNG():
relFITSFilePath = rebuildFilename(body['relFITSFilePath'])
sliceIndex0 = getIntValue(body['sliceIndex0'])
sliceIndex1 = getIntValue(body['sliceIndex1'])
ittName = body['ittName']
lutName = body['lutName']
vmName = body['vmName']
sessionID = getIntValue(body['sessionID'])
ret = dm.getSummedSliceRangeAsPNG(sliceIndex0, sliceIndex1, relFITSFilePath, ittName, lutName, vmName);
kwargs = {}
for x in ['ittName', 'lutName', 'vmName']:
if x in body :
kwargs[x]=body[x]
ret = dm.getSummedSliceRangeAsPNG(sliceIndex0, sliceIndex1, relFITSFilePath, **kwargs);
except Exception as e:
exc_type, exc_value, exc_traceback = sys.exc_info()
message = "%s ! %s" % (type(e), "".join(traceback.format_list(traceback.extract_tb(exc_traceback))))
......
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