本文整理汇总了Python中DIRAC.Interfaces.API.Dirac.Dirac.replicateFile方法的典型用法代码示例。如果您正苦于以下问题:Python Dirac.replicateFile方法的具体用法?Python Dirac.replicateFile怎么用?Python Dirac.replicateFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.Interfaces.API.Dirac.Dirac
的用法示例。
在下文中一共展示了Dirac.replicateFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_replicate
# 需要导入模块: from DIRAC.Interfaces.API.Dirac import Dirac [as 别名]
# 或者: from DIRAC.Interfaces.API.Dirac.Dirac import replicateFile [as 别名]
def do_replicate(self,args):
""" Replicate a given file to a given SE
usage:
replicate <LFN> <SE> [<SourceSE>]
"""
argss = args.split()
if len(args) < 2:
print "Error: unsufficient number of arguments"
lfn = argss[0]
lfn = self.getPath(lfn)
se = argss[1]
sourceSE = ''
if len(argss)>2:
sourceSE=argss[2]
if len(argss)>3:
localCache=argss[3]
try:
dirac = Dirac()
result = dirac.replicateFile(lfn,se,sourceSE,printOutput=True)
if not result['OK']:
print 'Error: %s' %(result['Message'])
elif not result['Value']:
print "Replica is already present at the target SE"
else:
print "File %s successfully replicated to the %s SE" % (lfn,se)
except Exception, x:
print "Error: replicate failed with exception: ", x
示例2: len
# 需要导入模块: from DIRAC.Interfaces.API.Dirac import Dirac [as 别名]
# 或者: from DIRAC.Interfaces.API.Dirac.Dirac import replicateFile [as 别名]
if len( args ) > 2:
sourceSE = args[2]
if len( args ) == 4:
localCache = args[3]
from DIRAC.Interfaces.API.Dirac import Dirac
dirac = Dirac()
exitCode = 0
try:
f = open( lfn, 'r' )
lfns = f.read().splitlines()
f.close()
except:
lfns = [lfn]
finalResult = {"Failed":[], "Successful":[]}
for lfn in lfns:
result = dirac.replicateFile( lfn, seName, sourceSE, localCache, printOutput = True )
if not result['OK']:
finalResult["Failed"].append( lfn )
print 'ERROR %s' % ( result['Message'] )
exitCode = 2
else:
finalResult["Successful"].append( lfn )
if len( lfns ) > 1:
print finalResult
DIRAC.exit( exitCode )