当前位置: 首页>>代码示例>>Python>>正文


Python Dirac.getMetadata方法代码示例

本文整理汇总了Python中DIRAC.Interfaces.API.Dirac.Dirac.getMetadata方法的典型用法代码示例。如果您正苦于以下问题:Python Dirac.getMetadata方法的具体用法?Python Dirac.getMetadata怎么用?Python Dirac.getMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DIRAC.Interfaces.API.Dirac.Dirac的用法示例。


在下文中一共展示了Dirac.getMetadata方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: open

# 需要导入模块: from DIRAC.Interfaces.API.Dirac import Dirac [as 别名]
# 或者: from DIRAC.Interfaces.API.Dirac.Dirac import getMetadata [as 别名]
      #continue
      f1l = open(full_file,'r')
      fread = f1l.read()
      f1l.close()
      hasbeensent2 = fread.split("\n")
      if not hasbeensent2[0] == "done":
        #need to be modified to have a different GUID for each file
        print "not done for GUID"
        f1l = open(full_file,'w')
        f1l.write('done'+'\n'+'on grid/castor: done'+'\n'+'number of event processed of type '+ typea[len(typea)-2]+' stripping '+ typea[len(typea)-1]+ ': '+hasbeensent2[0]+'\n'+str( datetime.datetime.now() ))
        f1l.close()
    mypfn = full_file
    dirac = Dirac()
    lfn = full_file.replace('/panasas/radiative/', '/lhcb/user/p/potterat/')
    print lfn
    metaData = dirac.getMetadata(lfn)
#    metaData = metaData['Value']['Successful'][lfn]
   # metaData2 = metaData2['Value']['Successful'][lfn2]
    print metaData
    if len(metaData['Value']['Successful']) < 1:
      test = dirac.addFile( lfn, mypfn, 'CERN-USER',  DIRAC.makeGuid(mypfn))
      print test
      if(test.has_key('Message')):
        #GUID Exists !
        test2 = test['Message'].split(" try again. ")
        print "remove the wrong path"
        rm.removeFile(test2[1])
        dirac.addFile( lfn, mypfn, 'CERN-USER',  DIRAC.makeGuid(mypfn))
     # mypfn.upload(lfn,'CERN-USER')
      print full_file,"copied to",lfn
      f1l = open('onGrid.txt','w')
开发者ID:cmdric,项目名称:dotfiles,代码行数:33,代码来源:UploadOnGrid.py

示例2: len

# 需要导入模块: from DIRAC.Interfaces.API.Dirac import Dirac [as 别名]
# 或者: from DIRAC.Interfaces.API.Dirac.Dirac import getMetadata [as 别名]
Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                     'Usage:',
                                     '  %s [option|cfgfile] ... LFN ...' % Script.scriptName,
                                     'Arguments:',
                                     '  LFN:      Logical File Name or file containing LFNs' ] ) )
Script.parseCommandLine( ignoreErrors = True )
lfns = Script.getPositionalArgs()

if len( lfns ) < 1:
  Script.showHelp()

from DIRAC.Interfaces.API.Dirac                       import Dirac
dirac = Dirac()
exitCode = 0
errorList = []

if len( lfns ) == 1:
  try:
    f = open( lfns[0], 'r' )
    lfns = f.read().splitlines()
    f.close()
  except:
    pass

result = dirac.getMetadata( lfns, printOutput = True )
if not result['OK']:
  print 'ERROR: ', result['Message']
  exitCode = 2

DIRAC.exit( exitCode )
开发者ID:DIRACGrid-test,项目名称:DIRAC,代码行数:32,代码来源:dirac-dms-lfn-metadata.py

示例3: open

# 需要导入模块: from DIRAC.Interfaces.API.Dirac import Dirac [as 别名]
# 或者: from DIRAC.Interfaces.API.Dirac.Dirac import getMetadata [as 别名]
    file_name += '.gz'
    f_in = open(file_label, 'rb')
    f_out = gzip.open(file_name, 'wb')
    f_out.writelines(f_in)
    f_out.close()
    f_in.close()

lfn=os.path.join('###LFN_BASE###', file_name)
wildcard='###WILDCARD###'
storage_elements=###SEs###

with closing(open('###LOCATIONSFILE_NAME###','ab')) as locationsfile:
    for se in storage_elements:
        sys.stdout.write('\nUploading file: \"%s\" as \"%s\" at \"%s\"\n' % (file_name, lfn, se))
        try:
            result = dirac.addFile(lfn, file_name, se)
        except Exception as x:
            sys.stdout.write('Exception running dirac.addFile command: %s' % str(x))
            break
        if result.get('OK',False) and lfn in result.get('Value',{'Successful':{}})['Successful']:
            guid = dirac.getMetadata(lfn)['Value']['Successful'][lfn]['GUID']
            locationsfile.write("DiracFile:::%s&&%s->%s:::['%s']:::%s\\n" % (wildcard, file_label, lfn, se, guid))
            locationsfile.flush()
            locationsfile.close()
            break
        errmsg+="(%s, %s), " % (se, result)
    else:
        locationsfile.write("DiracFile:::%s&&%s->###FAILED###:::File '%s' could not be uploaded to any SE (%s):::NotAvailable\\n" % (wildcard, file_label, file_name, errmsg))
        sys.stdout.write('Could not upload file %s' % file_name)

开发者ID:MannyMoo,项目名称:ganga,代码行数:31,代码来源:uploadScript.py


注:本文中的DIRAC.Interfaces.API.Dirac.Dirac.getMetadata方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。