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


Python Client.get_metadata方法代码示例

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


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

示例1: getZipFiles

# 需要导入模块: from rucio.client import Client [as 别名]
# 或者: from rucio.client.Client import get_metadata [as 别名]
 def getZipFiles(self, dids, rses):
     try:
         client = RucioClient()
         data = []
         iGUID = 0
         nGUID = 1000
         retVal = {}
         for did in dids:
             iGUID += 1
             scope, lfn = did.split(':')
             data.append({'scope':scope,'name':lfn})
             if len(data) % nGUID == 0 or iGUID == len(dids):
                 for tmpDict in client.list_replicas(data):
                     tmpScope = str(tmpDict['scope'])
                     tmpLFN = str(tmpDict['name'])
                     tmpDID = '{0}:{1}'.format(tmpScope, tmpLFN)
                     tmpRses = tmpDict['rses'].keys()
                     # RSE selection
                     for pfn, pfnData in tmpDict['pfns'].iteritems():
                         if (rses is None or pfnData['rse'] in rses) and pfnData['domain'] == 'zip':
                             zipFileName = pfn.split('/')[-1]
                             zipFileName = re.sub('\?.+$', '', zipFileName)
                             retVal[tmpDID] = client.get_metadata(tmpScope, zipFileName)
                             break
                 data = []
         return True, retVal
     except:
         errType, errVale = sys.exc_info()[:2]
         return False, '%s %s' % (errType,errVale)
开发者ID:PanDAWMS,项目名称:panda-server,代码行数:31,代码来源:DDM.py

示例2: getMetaData

# 需要导入模块: from rucio.client import Client [as 别名]
# 或者: from rucio.client.Client import get_metadata [as 别名]
 def getMetaData(self,dsn):
     # register dataset
     client = RucioClient()
     try:
         scope,dsn = self.extract_scope(dsn)
         return True,client.get_metadata(scope,dsn)
     except DataIdentifierNotFound:
         return True,None
     except:
         errType,errVale = sys.exc_info()[:2]
         return False,'%s %s' % (errType,errVale)
开发者ID:PanDAWMS,项目名称:panda-server,代码行数:13,代码来源:DDM.py

示例3: convertGoodRunListXMLtoDS

# 需要导入模块: from rucio.client import Client [as 别名]
# 或者: from rucio.client.Client import get_metadata [as 别名]
def convertGoodRunListXMLtoDS(tmpLog,goodRunListXML,goodRunDataType='',goodRunProdStep='',
                              goodRunListDS='',verbose=False):
    tmpLog.info('trying to convert GoodRunListXML to a list of datasets')  
    # return for failure
    failedRet = False,'',[]
    # import pyAMI
    try:
        import pyAMI.utils
        import pyAMI.client
        import pyAMI.atlas.api as AtlasAPI
    except:
        errType,errValue = sys.exc_info()[:2]
        print "%s %s" % (errType,errValue)
        tmpLog.error('cannot import pyAMI module')
        return failedRet
    # read XML
    try:
        gl_xml = open(goodRunListXML)
    except:
        tmpLog.error('cannot open %s' % goodRunListXML)
        return failedRet
    # parse XML to get run/lumi
    runLumiMap = {}
    import xml.dom.minidom
    rootDOM = xml.dom.minidom.parse(goodRunListXML)
    for tmpLumiBlock in rootDOM.getElementsByTagName('LumiBlockCollection'):
        for tmpRunNode in tmpLumiBlock.getElementsByTagName('Run'):
            tmpRunNum  = long(tmpRunNode.firstChild.data)
            for tmpLBRange in tmpLumiBlock.getElementsByTagName('LBRange'):
                tmpLBStart = long(tmpLBRange.getAttribute('Start'))
                tmpLBEnd   = long(tmpLBRange.getAttribute('End'))
                # append
                if not runLumiMap.has_key(tmpRunNum):
                    runLumiMap[tmpRunNum] = []
                runLumiMap[tmpRunNum].append((tmpLBStart,tmpLBEnd))
        kwargs = dict()
    kwargs['run_number'] = [unicode(x) for x in runLumiMap.keys()]
    kwargs['ami_status'] = 'VALID'
    if goodRunDataType != '':
        kwargs['type'] = goodRunDataType
    if goodRunProdStep != '':    
        kwargs['stream'] = goodRunProdStep
    if verbose:
        tmpLog.debug(kwargs)
    # convert for wildcard
    goodRunListDS = goodRunListDS.replace('*','.*')
    # list of datasets
    if goodRunListDS == '':
        goodRunListDS = []
    else:
        goodRunListDS = goodRunListDS.split(',')
    # execute
    try:
        amiclient = pyAMI.client.Client('atlas')
        amiOutDict = pyAMI.utils.smart_execute(amiclient, 'datasets', [], None, None, None, False, **kwargs).get_rows()
    except:
        errType,errValue = sys.exc_info()[:2]
        tmpLog.error("%s %s" % (errType,errValue))
        tmpLog.error('pyAMI failed')
        return failedRet
    # get dataset map
    if verbose:
        tmpLog.debug(amiOutDict)
    # parse
    rucioclient = RucioClient()
    datasetListFromAMI = []
    runDsMap = dict()
    for tmpVal in amiOutDict:
        if tmpVal.has_key('ldn'):
            dsName = str(tmpVal['ldn'])
            # check dataset names
            if goodRunListDS == []:    
                matchFlag = True
            else:
                matchFlag = False
                for tmpPatt in goodRunListDS:
                    if re.search(tmpPatt,dsName) != None:
                        matchFlag = True
            if not matchFlag:
                continue
            # get metadata
            try:
                tmpLog.debug("getting metadata for %s" % dsName)
                scope,dsn = extract_scope(dsName)
                meta =  rucioclient.get_metadata(scope, dsn)
                if meta['did_type'] == 'COLLECTION':
                    dsName += '/'
                datasetListFromAMI.append(dsName)
                tmpRunNum = meta['run_number']
                tmpLog.debug("run number : %s" % tmpRunNum)
                if tmpRunNum not in runDsMap:
                    runDsMap[tmpRunNum] = set()
                runDsMap[tmpRunNum].add(dsName)
            except:
                tmpLog.debug("failed to get metadata")
    # make string
    datasets = ''
    filesStr = []
    for tmpRunNum in runLumiMap.keys():
        for dsName in runDsMap[tmpRunNum]:
#.........这里部分代码省略.........
开发者ID:PanDAWMS,项目名称:panda-wnscript,代码行数:103,代码来源:PsubUtils.py


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