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


Python Dirac.getFile方法代码示例

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


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

示例1: do_get

# 需要导入模块: from DIRAC.Interfaces.API.Dirac import Dirac [as 别名]
# 或者: from DIRAC.Interfaces.API.Dirac.Dirac import getFile [as 别名]
 def do_get(self,args):
   """ Download file from grid and store in a local directory
   
       usage:
       
         get <lfn> [<local_directory>] 
   """
   
   argss = args.split()
   lfn = argss[0]
   lfn = self.getPath(lfn)
   dir = ''
   if len(argss)>1:
     dir = argss[1]
       
   dirac = Dirac()
   localCWD = ''
   if dir:
     localCWD = os.getcwd()
     os.chdir(dir)
   result = dirac.getFile(lfn)
   if localCWD:
     os.chdir(localCWD)
     
   if not result['OK']:
     print 'Error: %s' %(result['Message'])
   else:
     print "File %s successfully downloaded" % lfn      
开发者ID:KrzysztofCiba,项目名称:DIRAC,代码行数:30,代码来源:FileCatalogClientCLI.py

示例2: downloadFilesByFilelist

# 需要导入模块: from DIRAC.Interfaces.API.Dirac import Dirac [as 别名]
# 或者: from DIRAC.Interfaces.API.Dirac.Dirac import getFile [as 别名]
    def downloadFilesByFilelist(self, fileList, destDir=""):
        """downLoad a set of files form SE.
        use getFilesByFilelist() get a list of lfns and download these files.
        fileList get from function getFilesByDatesetName()

           Example usage:
           >>>badger.downloadFilesByFilelist(fileList)
        """
        errorDict = {}
        dirac = Dirac()
        # fileList = self.getFilesByDatasetName(dataset_name)
        for lfn in fileList:
            result = dirac.getFile(lfn, destDir, printOutput=False)
            if not result["OK"]:
                errorDict[lfn] = result["Message"]
        if errorDict:
            serr = S_ERROR()
            serr["errorDict"] = errorDict
            return serr
        else:
            return S_OK("File download successfully.")
开发者ID:besdiracgrid,项目名称:BESDIRAC,代码行数:23,代码来源:Badger.py

示例3: RPCClient

# 需要导入模块: from DIRAC.Interfaces.API.Dirac import Dirac [as 别名]
# 或者: from DIRAC.Interfaces.API.Dirac.Dirac import getFile [as 别名]
  if k.lower() in ["save"]:
    dir_save = v

gLogger.info("Dataset Name: ", dataset)
gLogger.info("Save in: ", dir_save)

# Get the list of LFNs in one dataset
from DIRAC.Core.DISET.RPCClient import RPCClient
transferRequest = RPCClient("Transfer/Dataset")
res = transferRequest.list(dataset)

if not res["OK"]:
  gLogger.error(res)
  DIRAC.exit(-1)

file_list = [v[1] for v in res["Value"]]
gLogger.debug("File List", file_list)
# Begin to save file
# Refer to dirac-dms-get-file.py in DIRAC/Interfaces/scripts


from DIRAC.Interfaces.API.Dirac import Dirac
dirac = Dirac()
res = dirac.getFile( file_list, destDir = dir_save, printOutput = True )

if not res["OK"]:
  gLogger.error(res)
  DIRAC.exit(-1)

DIRAC.exit(0)
开发者ID:atsareg,项目名称:BESDIRAC,代码行数:32,代码来源:besdirac-transfer-dataset-download.py

示例4: len

# 需要导入模块: from DIRAC.Interfaces.API.Dirac import Dirac [as 别名]
# 或者: from DIRAC.Interfaces.API.Dirac.Dirac import getFile [as 别名]
Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                     'Usage:',
                                     '  %s [option|cfgfile] ... LFN ...' % Script.scriptName,
                                     'Arguments:',
                                     '  LFN:      Logical File Name or file containing LFNs' ] ) )
Script.parseCommandLine( ignoreErrors = True )
lfns = Script.getPositionalArgs()

if len( lfns ) < 1:
  Script.showHelp()

from DIRAC.Interfaces.API.Dirac                       import Dirac
dirac = Dirac()
exitCode = 0

if len( lfns ) == 1:
  try:
    f = open( lfns[0], 'r' )
    lfns = f.read().splitlines()
    f.close()
  except:
    pass

result = dirac.getFile( lfns, printOutput = True )
if not result['OK']:
  print 'ERROR %s' % ( result['Message'] )
  exitCode = 2

DIRAC.exit( exitCode )
开发者ID:sbel,项目名称:bes3-jinr,代码行数:31,代码来源:dirac-dms-get-file.py

示例5: open

# 需要导入模块: from DIRAC.Interfaces.API.Dirac import Dirac [as 别名]
# 或者: from DIRAC.Interfaces.API.Dirac.Dirac import getFile [as 别名]
    file_list = result.split()[-1]
else:
    file_list = args.file_list

# try reading the lfns file
try:
    GRID_file_list = open(file_list).read()
except IOError:
    raise IOError("cannot read lfns file list...")


file_collection = []
for line in GRID_file_list:
    line = line.strip()

    if args.match not in line:
        continue

    # don't download if already in current directory
    if glob(basename(line)):
        continue

    if len(file_collection) < 100:
        file_collection.append(line)
    else:
        dirac.getFile(file_collection, destDir=args.outdir)
        file_collection = []

if file_collection:
    dirac.getFile(file_collection, destDir=args.outdir)
开发者ID:tino-michael,项目名称:tino_cta,代码行数:32,代码来源:download_files_from_dirac.py

示例6: parseCommandLine

# 需要导入模块: from DIRAC.Interfaces.API.Dirac import Dirac [as 别名]
# 或者: from DIRAC.Interfaces.API.Dirac.Dirac import getFile [as 别名]
import os
## NB parseCommandLine first then import Dirac!!
from DIRAC.Core.Base.Script import parseCommandLine
from DIRAC.Interfaces.API.Dirac import Dirac
parseCommandLine()
dirac=Dirac()
dirac.getFile('###LFN###', os.getcwd())
开发者ID:MannyMoo,项目名称:ganga,代码行数:9,代码来源:downloadScript.py

示例7: Dirac

# 需要导入模块: from DIRAC.Interfaces.API.Dirac import Dirac [as 别名]
# 或者: from DIRAC.Interfaces.API.Dirac.Dirac import getFile [as 别名]
#!/usr/bin/env python2

from os.path import basename, expandvars
from glob import glob

from DIRAC.Core.Base import Script
Script.parseCommandLine()
from DIRAC.Interfaces.API.Dirac import Dirac

dirac = Dirac()

file_collection = []
for line in open(expandvars('$CTA_SOFT/tino_cta/vo.cta.in2p3.fr-user-t-tmichael.lfns')):
    line = line.strip()

    if "prod3b/paranal_LND/classified_events_proton_tail" not in line:
        continue

    # don't download if already in current directory
    if glob(basename(line)):
        continue

    if len(file_collection) < 100:
        file_collection.append(line)
    else:
        dirac.getFile(file_collection)
        file_collection = []

if file_collection:
    dirac.getFile(file_collection)
开发者ID:jdhp-sap,项目名称:tino_cta,代码行数:32,代码来源:download_files_from_dirac.py

示例8: _downloadSingleFile

# 需要导入模块: from DIRAC.Interfaces.API.Dirac import Dirac [as 别名]
# 或者: from DIRAC.Interfaces.API.Dirac.Dirac import getFile [as 别名]
 def _downloadSingleFile(self, remotePath, localPath):
   gLogger.debug('getfile from %s to %s' % (remotePath, localPath))
   dirac = Dirac()
   result = dirac.getFile(remotePath, os.path.dirname(localPath))
   return result['OK']
开发者ID:besdiracgrid,项目名称:BESDIRAC,代码行数:7,代码来源:DfcGetFile.py


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