本文整理汇总了Python中DIRAC.Resources.Catalog.FileCatalogClient.FileCatalogClient.getReplicas方法的典型用法代码示例。如果您正苦于以下问题:Python FileCatalogClient.getReplicas方法的具体用法?Python FileCatalogClient.getReplicas怎么用?Python FileCatalogClient.getReplicas使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.Resources.Catalog.FileCatalogClient.FileCatalogClient
的用法示例。
在下文中一共展示了FileCatalogClient.getReplicas方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FileStatusTransformationAgent
# 需要导入模块: from DIRAC.Resources.Catalog.FileCatalogClient import FileCatalogClient [as 别名]
# 或者: from DIRAC.Resources.Catalog.FileCatalogClient.FileCatalogClient import getReplicas [as 别名]
#.........这里部分代码省略.........
res = self.tClient.setTaskStatus(transID, transFile['TaskID'], 'Waiting')
if not res['OK']:
self.logError('Failure to set Waiting status for Task ID: ', "%s %s" % (transFile['TaskID'], res['Message']))
continue
self.accounting[RESET_REQUEST].append({'LFN': transFile['LFN'],
'Status': transFile['Status'],
'AvailableOnSource': transFile['AvailableOnSource'],
'AvailableOnTarget': transFile['AvailableOnTarget']})
if setFilesUnused:
self.setFileStatus(transID, setFilesUnused, 'Unused')
if setFilesAssigned:
self.setFileStatus(transID, setFilesAssigned, 'Assigned')
return S_OK()
def applyActions(self, transID, actions):
""" sets new file statuses and resets requests """
for action, transFiles in actions.iteritems():
if action == SET_PROCESSED and transFiles:
self.setFileStatus(transID, transFiles, 'Processed')
if action == SET_DELETED and transFiles:
self.setFileStatus(transID, transFiles, 'Deleted')
if action == RETRY and transFiles:
# if there is a request in RMS then reset request otherwise set file status unused
self.retryFiles(transID, transFiles)
def existsInFC(self, storageElements, lfns):
""" checks if files have replicas registered in File Catalog for all given storageElements """
res = self.fcClient.getReplicas(lfns)
if not res['OK']:
return res
result = {}
result['Successful'] = {}
result['Failed'] = {}
setOfSEs = set(storageElements)
for lfn, msg in res['Value']['Failed'].iteritems():
if msg == 'No such file or directory':
result['Successful'][lfn] = False
else:
result['Failed'][lfn] = msg
# check if all replicas are registered in FC
filesFoundInFC = res['Value']['Successful']
for lfn, replicas in filesFoundInFC.iteritems():
result['Successful'][lfn] = setOfSEs.issubset(replicas.keys())
return S_OK(result)
def existsOnSE(self, storageElements, lfns):
""" checks if the given files exist physically on a list of storage elements"""
result = {}
result['Failed'] = {}
result['Successful'] = {}
if not lfns:
return S_OK(result)
voName = lfns[0].split('/')[1]
示例2: __init__
# 需要导入模块: from DIRAC.Resources.Catalog.FileCatalogClient import FileCatalogClient [as 别名]
# 或者: from DIRAC.Resources.Catalog.FileCatalogClient.FileCatalogClient import getReplicas [as 别名]
#.........这里部分代码省略.........
"""
countDict = {}
if type(fileList) != type([]):
fileList = [fileList]
for file in fileList:
result = self.getFileMetaVal(file)
if len(result) != 0:
count = result["count"]
if plus:
count += 1
else:
if count > 0:
count -= 1
cDict = {"count": count}
self.registerFileMetadata(file, cDict)
countDict[file] = count
else:
print "Failed reCalculate value of count of file %s" % file
countDict[file] = -1
return countDict
def removeFile(self, lfn):
"""remove file on DFC
"""
result = self.client.removeFile(lfn)
if not result["OK"]:
return S_ERROR(result)
else:
return S_OK()
def getPFN(self, lfn):
"""get replicas by lfn"""
result = self.client.getReplicas(lfn)
# print result
if not result["OK"]:
return S_ERROR(result)
else:
return S_OK(result["Value"]["Successful"][lfn]["IHEPD-USER"])
def getSize(self, lfns):
"""get the size of the given lfn"""
result = self.client.getFileSize(lfns)
if result["OK"]:
if result["Value"]["Successful"]:
retVal = result["Value"]["Successful"]
else:
retVal = {}
return retVal
def getFilesByMetadataQuery(self, query):
"""Return a list of LFNs satisfying given query conditions.
Example usage:
>>> brunH_GT_29756adger.getFilesByMetadataQuery('resonance=jpsi bossVer=6.5.5 round=exp1')
['/bes/File/jpsi/6.5.5/data/all/exp1/file1', .....]
"""
# TODO: checking of output, error catching
fc = self.client
# TODO: calling the FileCatalog CLI object and its private method
# is not a good way of doing this! but use it to allow construction of
# the query meantime, until createQuery is made a public method
cli = FileCatalogClientCLI(fc)
metadataDict = cli._FileCatalogClientCLI__createQuery(query)