def checksumChecker(localFilename, checksums): """ Check given checksums vs. what's on disk """ try: adler32 = readAdler32(localFilename) if adler32 == checksums['adler32']: return True else: return False except: cksum = readCksum(localFilename) if cksum == checksums['cksum']: return True else: return False return False
def execute(self, emulator = None, **overrides): """ _execute_ """ # Are we using emulators again? if (emulator != None): return emulator.emulate( self.step, self.job ) overrides = {} if hasattr(self.step, 'override'): overrides = self.step.override.dictionary_() # Find alternate stageout location self.altLFN = overrides.get('altLFN', None) logging.info("Beginning Steps.Executors.LogArchive.Execute") logging.info("Using the following overrides: %s " % overrides) logging.info("Step is: %s" % self.step) # Wait timout for stageOut waitTime = overrides.get('waitTime', 3600 + (self.step.retryDelay * self.step.retryCount)) matchFiles = [ ".log$", "FrameworkJobReport", "Report.pkl", "Report.pcl", "^PSet.py$", "^PSet.pkl$" ] #Okay, we need a stageOut Manager useNewStageOutCode = False if getattr(self.step, 'newStageout', False) or \ (overrides.has_key('newStageOut') and overrides.get('newStageOut')): useNewStageOutCode = True if not useNewStageOutCode: # old style manager = StageOutMgr.StageOutMgr(**overrides) manager.numberOfRetries = self.step.retryCount manager.retryPauseTime = self.step.retryDelay else: # new style logging.info("LOGARCHIVE IS USING NEW STAGEOUT CODE") manager = WMCore.Storage.FileManager.StageOutMgr( retryPauseTime = self.step.retryDelay, numberOfRetries = self.step.retryCount, **overrides) #Now we need to find all the reports logFilesForTransfer = [] #Look in the taskSpace first logFilesForTransfer.extend(self.findFilesInDirectory(self.stepSpace.taskSpace.location, matchFiles)) #What if it's empty? if len(logFilesForTransfer) == 0: msg = "Could find no log files in job" logging.error(msg) return logFilesForTransfer #Now that we've gone through all the steps, we have to tar it out tarName = 'logArchive.tar.gz' tarBallLocation = os.path.join(self.stepSpace.location, tarName) tarBall = tarfile.open(tarBallLocation, 'w:gz') for f in logFilesForTransfer: tarBall.add(name = f, arcname = f.replace(self.stepSpace.taskSpace.location, '', 1).lstrip('/')) tarBall.close() fileInfo = {'LFN': self.getLFN(tarName), 'PFN' : tarBallLocation, 'SEName' : None, 'GUID' : None } signal.signal(signal.SIGALRM, alarmHandler) signal.alarm(waitTime) try: manager(fileInfo) self.report.addOutputModule(moduleName = "logArchive") reportFile = {"lfn": fileInfo["LFN"], "pfn": fileInfo["PFN"], "location": fileInfo["SEName"], "module_label": "logArchive", "events": 0, "size": 0, "merged": False, "checksums": {'md5': BasicAlgos.getMD5(tarBallLocation), 'adler32': readAdler32(tarBallLocation), 'cksum': readCksum(tarBallLocation)}} self.report.addOutputFile(outputModule = "logArchive", file = reportFile) except Alarm: msg = "Indefinite hang during stageOut of logArchive" logging.error(msg) self.report.addError(self.stepName, 60404, "LogArchiveTimeout", msg) self.report.persist("Report.pkl") raise WMExecutionFailure(60404, "LogArchiveTimeout", msg) except WMException, ex: self.report.addError(self.stepName, 60307, "LogArchiveFailure", str(ex)) self.report.setStepStatus(self.stepName, 0) self.report.persist("Report.pkl") raise ex