Download ESO NG/AMS - User`s Manual

Transcript
ESO
NG/AMS - User's Manual
Doc.
Issue
Date
Page
Check that the checksum of the file is correct.
parDic:
Dictionary with disk information (ngamsPhysDiskInfo objects)
(dictionary).
filename:
Name of FITS file (string).
Returns:
Void.
"""
# Only do check if the checksum_util parameter is set.
if (not parDic.has_key("checksum_util")): return
# Execute the checksum routine and evaluate result.
info(2,"Invoking checksum test utility: " + parDic["checksum_util"] +\
" on file: " + filename)
res = ngamsPlugInApi.execCmd(parDic["checksum_util"] + " " + filename)
if (int(res[0]) != 0):
errMsg = "Problem occurred invoking checksum check utility: " +\
parDic["checksum_util"]
errMsg = genLog("NGAMS_ER_DAPI", [errMsg])
error(errMsg)
raise exceptions.Exception, errMsg
if (res[1] != parDic["checksum_result"]):
errMsg = "Executing checksum utility: " + parDic["checksum_util"] +\
" gave unexpected result. Result: [" + res[1] + "]. " +\
"Expected Result: [" + parDic["checksum_result"] + "]."
errMsg = genLog("NGAMS_ER_BAD_FILE", [filename, "ngamsFitsPlugIn",
errMsg])
error(errMsg)
raise exceptions.Exception, errMsg
# DAPI function.
def ngamsFitsPlugIn(srvObj,
reqPropsObj):
"""
Data Archiving Plug-In to handle archiving of FITS files.
srvObj:
Reference to NG/AMS Server Object (ngamsServer).
reqPropsObj:
NG/AMS request properties object (ngamsReqProps).
Returns:
Standard NG/AMS Data Archiving Plug-In Status
as generated by: ngamsPlugInApi.genDapiSuccessStat()
(ngamsDapiStatus).
"""
stagingFilename = ""
trgFilename = ""
mountPoint = ""
info(1,"Plug-In handling data for file with URI: " +
os.path.basename(reqPropsObj.getFileUri()))
diskInfo = reqPropsObj.getTargDiskInfo()
parDic = ngamsPlugInApi.parseDapiPlugInPars(srvObj.getCfg(),
reqPropsObj.getMimeType())
# If the file is already compressed, we have to decompress it.
tmpFn = reqPropsObj.getStagingFilename()
if ((tmpFn.find(".Z") != -1) or (tmpFn.find(".gz") != -1)):
ngamsPlugInApi.execCmd("gunzip " + tmpFn)
reqPropsObj.setStagingFilename(os.path.splitext(tmpFn)[0])
stagingFilename = reqPropsObj.getStagingFilename()
comprExt = ""
if (parDic.has_key("compression")):
if (string.split(parDic["compression"], " ")[0] == "compress"):
comprExt = "Z"
elif (string.split(parDic["compression"], " ")[0] == "gzip"):
comprExt = "gz"
# Check file (size + checksum).
checkFitsFileSize(stagingFilename)
checkChecksum(parDic, stagingFilename)
# Get various information about the file being handled.
dpIdInfo = getDpIdInfo(stagingFilename)
dpId = dpIdInfo[1]
dateDirName = dpIdInfo[2]
fileVersion, relPath, relFilename,\
complFilename, fileExists =\
ngamsPlugInApi.genFileInfo(srvObj.getDb(), srvObj.getCfg(),
reqPropsObj, diskInfo,
stagingFilename, dpId, dpId,
[dateDirName], [comprExt])
# If a compression application is specified, apply this.
uncomprSize = ngamsPlugInApi.getFileSize(stagingFilename)
if (parDic["compression"] != ""):
VLT-MAN-ESO-19400-2739
2
08/01/2003
81 of 126