def openCompressedFile(ycsbfile, dict, key, decompress, overwrite, logger):
try:
file = gzip.open(ycsbfile,"r")
dict[key]=cPickle.load(file)
file.close()
except Exception, e:
logger.error("Can't open '%s'. Is it really a compressed .ydc file?" %(ycsbfile), exc_info=True)
os._exit(-1)
# if you truly just want to decompress it, stop after saving plain ycsb file
if decompress:
try:
newFileName=os.path.splitext(os.path.basename(ycsbfile))[0]+".log"
if (not Util.check_file_exists(newFileName) or overwrite) and os.access(".", os.W_OK):
if key in dict.keys() and dict[key] != None:
decompressFile(dict[key], newFileName, logger)
else:
logger.error("Dictionary does not have filecontent or is null." , exc_info=True)
os._exit(-1)
else:
logger.error("Can't create '%s' to write. Does it already exist?" %(newFileName), exc_info=True)
os._exit(-1)
except Exception, e:
logger.error("Can't open '%s'." %("%s.log.log" %(os.path.basename(ycsbfile))), exc_info=True)
os._exit(-1)
评论列表
文章目录