def createFileMetadata(outFiles, job, outsDict, dsname, datasetDict, sitename): """ create the metadata for the output + log files """ ec = 0 # get/assign guids to the output files if outFiles: tolog("outFiles=%s"%str(outFiles)) if not pUtil.isBuildJob(outFiles): ec, job.pilotErrorDiag, job.outFilesGuids = RunJobUtilities.getOutFilesGuids(job.outFiles, job.workdir) if ec: # missing PoolFileCatalog (only error code from getOutFilesGuids) return ec, job, None else: tolog("Build job - do not use PoolFileCatalog to get guid (generated)") else: tolog("This job has no output files") # get the file sizes and checksums for the local output files # WARNING: any errors are lost if occur in getOutputFileInfo() ec, pilotErrorDiag, fsize, checksum = pUtil.getOutputFileInfo(list(outFiles), getChecksumCommand(), skiplog=True, logFile=job.logFile) if ec != 0: tolog("!!FAILED!!2999!! %s" % (pilotErrorDiag)) failJob(job.result[1], ec, job, pilotserver, pilotport, pilotErrorDiag=pilotErrorDiag) if logguid: guid = logguid else: guid = job.tarFileGuid # create preliminary metadata (no metadata yet about log file - added later in pilot.py) _fname = "%s/metadata-%d.xml" % (job.workdir, job.jobId) try: _status = pUtil.PFCxml(job.experiment, _fname, list(job.outFiles), fguids=job.outFilesGuids, fntag="lfn", alog=job.logFile, alogguid=guid,\ fsize=fsize, checksum=checksum, analJob=analJob) except Exception, e: pilotErrorDiag = "PFCxml failed due to problematic XML: %s" % (e) tolog("!!WARNING!!1113!! %s" % (pilotErrorDiag)) failJob(job.result[1], error.ERR_MISSINGGUID, job, pilotserver, pilotport, pilotErrorDiag=pilotErrorDiag)