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


Python Client.get_dataset_by_guid方法代码示例

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


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

示例1: listDatasetsByGUIDs

# 需要导入模块: from rucio.client import Client [as 别名]
# 或者: from rucio.client.Client import get_dataset_by_guid [as 别名]
 def listDatasetsByGUIDs(self,guids):
     client = RucioClient()
     result = {}
     for guid in guids:
         datasets = [str('%s:%s' % (i['scope'], i['name'])) for i in client.get_dataset_by_guid(guid)]
         result[guid] = datasets
     return result
开发者ID:PanDAWMS,项目名称:panda-server,代码行数:9,代码来源:DDM.py

示例2: listDatasetsByGUIDs

# 需要导入模块: from rucio.client import Client [as 别名]
# 或者: from rucio.client.Client import get_dataset_by_guid [as 别名]
def listDatasetsByGUIDs(guids,dsFilter,tmpLog,verbose=False,forColl=False):
    # rucio API
    try:
        client = RucioClient()
    except:
        errtype,errvalue = sys.exc_info()[:2]
        errStr = "failed to get rucio API with %s:%s" % (errtype,
                                                         errvalue)
        tmpLog.error(errStr)
        sys.exit(EC_Failed)
    # get filter
    dsFilters = []
    if dsFilter != '':
        dsFilters = dsFilter.split(',')
    retMap = {}
    allMap = {}
    iLookUp = 0
    guidLfnMap = {}
    checkedDSList = []
    # loop over all GUIDs
    for guid in guids:
        # check existing map to avid redundant lookup
        if guidLfnMap.has_key(guid):
            retMap[guid] = guidLfnMap[guid]
            continue
        tmpLog.debug('getting datasetname from ddm for %s' % guid)
        iLookUp += 1
        if iLookUp % 20 == 0:
            time.sleep(1)
        # get datasets
        outMap = {guid: [str('%s:%s' % (i['scope'], i['name'])) for i in client.get_dataset_by_guid(guid)]}
        tmpLog.debug(outMap)
        # datasets are deleted
        if outMap == {}:
            allMap[guid] = []
            continue
        # check with filter
        tmpDsNames = []
        tmpAllDsNames = []
        for tmpDsName in outMap.values()[0]:
            # ignore junk datasets
            if tmpDsName.startswith('panda') or \
                   tmpDsName.startswith('user') or \
                   tmpDsName.startswith('group') or \
                   re.search('_sub\d+$',tmpDsName) != None or \
                   re.search('_dis\d+$',tmpDsName) != None or \
                   re.search('_shadow$',tmpDsName) != None:
                continue
            tmpAllDsNames.append(tmpDsName)
            # check with filter            
            if dsFilters != []:
                flagMatch = False
                for tmpFilter in dsFilters:
                    # replace . to \.                    
                    tmpFilter = tmpFilter.replace('.','\.')                    
                    # replace * to .*
                    tmpFilter = tmpFilter.replace('*','.*')
                    if re.search('^'+tmpFilter,tmpDsName) != None:
                        flagMatch = True
                        break
                # not match
                if not flagMatch:
                    continue
            # append    
            tmpDsNames.append(tmpDsName)
        # empty
        if tmpDsNames == []:
            # there may be multiple GUIDs for the same event, and some may be filtered by --eventPickDS
            allMap[guid] = tmpAllDsNames
            continue
        # duplicated
        if len(tmpDsNames) != 1:
            if not forColl:
                errStr = "there are multiple datasets %s for GUID:%s. Please set --eventPickDS and/or --eventPickStreamName to choose one dataset"\
                         % (str(tmpAllDsNames),guid)
            else:
                errStr = "there are multiple datasets %s for GUID:%s. Please set --eventPickDS to choose one dataset"\
                         % (str(tmpAllDsNames),guid)
            tmpLog.error(errStr)
            sys.exit(EC_Failed)
        # get LFN
        if not tmpDsNames[0] in checkedDSList:
            tmpMap,tmpStamp = dq2.listFilesInDataset(tmpDsNames[0],verbose)
            for tmpGUID,tmpVal in tmpMap.iteritems():
                guidLfnMap[tmpGUID] = (tmpDsNames[0],tmpVal['lfn'])
            checkedDSList.append(tmpDsNames[0])
        # append
        if not guidLfnMap.has_key(guid):
            errStr = "LFN for %s in not found in %s" % (guid,tmpDsNames[0])
            tmpLog.error(errStr)
            sys.exit(EC_Failed)
        retMap[guid] = guidLfnMap[guid]
    # return
    return retMap,allMap
开发者ID:PanDAWMS,项目名称:panda-wnscript,代码行数:96,代码来源:PsubUtils.py


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