コード例 #1
0
ファイル: DiracLHCb.py プロジェクト: antolu/LHCbDIRAC
  def getAccessURL(self, lfn, storageElement, protocol=None, printOutput=False):
    """Allows to retrieve an access URL for an LFN replica given a valid DIRAC SE
       name.  Contacts the file catalog and contacts the site SRM endpoint behind
       the scenes.

       Example Usage:

       >>> print dirac.getAccessURL('/lhcb/data/CCRC08/DST/00000151/0000/00000151_00004848_2.dst','CERN-RAW')
       {'OK': True, 'Value': {'Successful': {'srm://...': {'SRM2': 'rfio://...'}}, 'Failed': {}}}

       :param lfn: Logical File Name (LFN)
       :type lfn: str or python:list
       :param storageElement: DIRAC SE name e.g. CERN-RAW
       :type storageElement: string
       :param printOutput: Optional flag to print result
       :type printOutput: boolean
       :returns: S_OK,S_ERROR
    """
    ret = self._checkFileArgument(lfn, 'LFN')
    if not ret['OK']:
      return ret
    lfn = ret['Value']
    if isinstance(lfn, basestring):
      lfn = [lfn]
    results = getAccessURL(lfn, storageElement, protocol=protocol)
    if printOutput:
      printDMResult(results, empty="File not at SE", script="dirac-dms-lfn-accessURL")
    return results
コード例 #2
0
            print "  Finished:".ljust(30), finished
            print "  Data taking description:".ljust(30), datataking
            print "  Processing pass:"******"  TCK:".ljust(30), tck
            print "  Stream:".ljust(30), stream
            just = len(str(fsize)) + 3
            print "  FullStat:".ljust(30), str(fullstat).ljust(
                just), " Total: ".ljust(10) + str(sum(fullstat))
            print "  Number of events:".ljust(30), str(nbofe).ljust(
                just), " Total:".ljust(10) + str(sum(nbofe))
            print "  Number of files:".ljust(30), str(nboff).ljust(
                just), " Total: ".ljust(10) + str(sum(nboff))
            print "  File size:".ljust(30), str(fsize).ljust(
                just), " Total: ".ljust(10) + str(sum(fsize))
            sep = 20 * '='
        elif item:
            failed[run] = res['Message']
    if item:
        progressBar.endLoop()

if item:
    if not failed:
        del failed
    if byValue:
        for val in success:
            success[val] = ('(%d runs) - ' % len(success[val])) + (','.join(
                sorted(str(run) for run in success[val])))
    printDMResult(S_OK(result),
                  empty='None',
                  script='dirac-bookkeeping-run-information')
コード例 #3
0
if len(args) < 1:
    Script.showHelp()
parameters = None
for switch in Script.getUnprocessedSwitches():
    if switch[0] == 'Parameters':
        parameters = switch[1].split(',')

from DIRAC.Interfaces.API.Dirac import Dirac, parseArguments

dirac = Dirac()

results = {'OK': True, 'Value': {'Successful': {}, 'Failed': {}}}
success = results['Value']['Successful']
failed = results['Value']['Failed']
for job in parseArguments(args):
    jobStr = 'Job %s' % job
    result = dirac.getJobParameters(job, printOutput=False)
    if not result['OK']:
        failed.update({jobStr: result['Message']})
    elif not result['Value']:
        failed.update({jobStr: 'Job not found'})
    elif parameters:
        params = dict((key, val) for key, val in result['Value'].iteritems()
                      if key in parameters)
        success.update({jobStr: params})
    else:
        success.update({jobStr: result['Value']})

DIRAC.exit(printDMResult(results, empty="Job not found"))
コード例 #4
0
        outputFiles = True
    jobidList = []
    for jobid in args:
        if os.path.exists(jobid):
            bkScript.setJobidsFromFile(jobid)
        else:
            jobidList += jobid.split(',')
    jobidList += bkScript.getOption('JobIDs', [])
    if not jobidList:
        print "No jobID provided!"
        Script.showHelp()
        DIRAC.exit(0)

    from LHCbDIRAC.BookkeepingSystem.Client.BookkeepingClient import BookkeepingClient
    retVal = BookkeepingClient().getJobInputOutputFiles(jobidList)
    if retVal['OK']:
        success = retVal['Value']['Successful']
        for job in success:
            # Remove from input the files that are also output! This happens because the output of step 1 can be the input of step 2...
            # only worth if input files are requested though
            if inputFiles:
                success[job]['InputFiles'] = sorted(
                    set(success[job]['InputFiles']) -
                    set(success[job]['OutputFiles']))

            if not inputFiles or not outputFiles:
                success[job].pop(
                    'InputFiles' if not inputFiles else 'OutputFiles')

    printDMResult(retVal, empty="File does not exists in the Bookkeeping")
コード例 #5
0
nonExisting = []
dirac = Dirac()

for localFile in files:
  if os.path.exists(localFile):
    existFiles[os.path.realpath(localFile)] = localFile
  elif localFile.startswith('/lhcb'):
    res = dirac.getReplicas(localFile, active=True, preferDisk=True)
    if res['OK'] and localFile in res['Value']['Successful']:
      ses = res['Value']['Successful'][localFile].keys()
      for se in ses:
        res = dirac.getAccessURL(localFile, se, protocol=['root', 'xroot'])
        if res['OK'] and localFile in res['Value']['Successful']:
          existFiles[res['Value']['Successful'][localFile]] = "%s @ %s" % (localFile, se)
    else:
      nonExisting.append(localFile)
  elif localFile.startswith('root:'):
    existFiles[localFile] = localFile
  else:
    nonExisting.append(localFile)

fileGUIDs = getRootFileGUIDs(existFiles.keys())
for status in ('Successful', 'Failed'):
  for file in fileGUIDs.get('Value', {}).get(status, {}):
    fileGUIDs['Value'][status][existFiles.get(file, file)] = fileGUIDs['Value'][status].pop(file)
if nonExisting:
  fileGUIDs['Value']['Failed'].update(dict.fromkeys(nonExisting, 'Non existing file'))
printDMResult(fileGUIDs)

DIRAC.exit(0)