本文整理汇总了Python中DIRAC.Resources.Catalog.FileCatalogClient.FileCatalogClient.isFile方法的典型用法代码示例。如果您正苦于以下问题:Python FileCatalogClient.isFile方法的具体用法?Python FileCatalogClient.isFile怎么用?Python FileCatalogClient.isFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.Resources.Catalog.FileCatalogClient.FileCatalogClient
的用法示例。
在下文中一共展示了FileCatalogClient.isFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: registerInputData
# 需要导入模块: from DIRAC.Resources.Catalog.FileCatalogClient import FileCatalogClient [as 别名]
# 或者: from DIRAC.Resources.Catalog.FileCatalogClient.FileCatalogClient import isFile [as 别名]
def registerInputData(filepath, size, prefix = '/cepc/lustre-ro'):
infoDict = {}
infoDict['PFN'] = ''
infoDict['Size'] = size
infoDict['SE'] = 'IHEP-STORM'
infoDict['GUID'] = commands.getoutput('uuidgen')
infoDict['Checksum'] = ''
fileDict = {}
lfn = prefix + filepath
fileDict[lfn] = infoDict
fcc = FileCatalogClient('DataManagement/FileCatalog')
rm = ReplicaManager()
result = {}
result['lfn'] = lfn
result['is_registered'] = False
#查询
for repeatTimes in range(10):
is_registered = fcc.isFile(lfn)
if (is_registered['OK'] and is_registered['Value']['Successful'].has_key(lfn)):
break
# else:
# continue
if not is_registered['OK']:#查询失败
result['is_registered'] = 'querry error. unkown'
print 'Failed to query %s in DFC. Error message is %s' %(lfn, is_registered['Message'])
if is_registered['Value']['Successful'][lfn]:#已注册
result['is_registered'] = True
for repeatTimes in range(10):
is_removed = rm.removeCatalogFile(lfn)#删除
if (is_removed['OK'] and is_removed['Value']['Successful'][lfn]['FileCatalog']):
result['is_removed'] = True
break
# else:
# continue
if not is_removed['OK']:#删除失败
result['is_removed'] = 'remove error'
print 'Failed to remove %s from DFC.' %lfn
#add
for repeatTimes in range(10):
is_added = fcc.addFile(fileDict)#add/register
if (is_added['OK'] and is_added['Value']['Successful'][lfn]):
result['OK'] = True
return result
# else:
# continue
if not is_added['OK']:#add unsuccessfully
result['OK'] = False
result['Message'] = is_added['Message']
elif is_added['Value']['Failed']:
result['OK'] = False
result['Message'] = 'Failed to add file' + lfn
return result