Ejemplo n.º 1
0
class DownloadWorker(IWorker):
  """
  """
  #if file failed download,then append in errorDict
  errorDict = {}

  def __init__(self):
    self.badger = Badger()
    if queryFlag:
      self.m_list = self.badger.getFilesByMetadataQuery(setQuery)
    elif setNameFlag:
      self.m_list = self.badger.getFilesByDatasetName(setName)
    elif dfcDirFlag:
      self.m_list = self.badger.listDir(dfcDir)
    elif filenameFlag:
      with open(filename) as f:
        for line in f:
          self.m_list.append(line.strip())

  def get_file_list(self):
    return self.m_list

  def Do(self, item):
    badger = Badger()
    result = badger.downloadFilesByFilelist([item])#,destDir)
    if not result['OK']:
      #print result['Message'],type(result['Message'])
      errorDict.update(result['Message'])
      print errorDict
Ejemplo n.º 2
0
 def getFileList(self):
     badger = Badger()
     result = badger.getFilesByDatasetName(setName)
     fileList = []
     if result['OK']:
         fileList = result['Value']
         if fileList:
             self.dirName = os.path.dirname(fileList[0])
     for file in fileList:
         print >> self.listFile, os.path.basename(file)
     self.readyNum = len(fileList)
     self.listFile.close()
     time_print('There are %s files ready for download' % self.readyNum)
#!/usr/bin/env python
#mtime:2013/12/09
"""
besdirac-dms-dataset-filelist
  get the filelist of the given dataset
  Usage:
    besdirac-dms-dataset-filelist<datasetname>
"""

__RCSID__ = "$Id$"
import pprint
from DIRAC import S_OK, S_ERROR, gLogger, exit
from DIRAC.Core.Base import Script

Script.setUsageMessage(__doc__)
args = Script.getPositionalArgs()

if len(args) != 1:
    Script.showHelp()
datasetName = args[0]

from IHEPDIRAC.Badger.API.Badger import Badger
badger = Badger()
result = badger.getFilesByDatasetName(datasetName)
if result['OK']:
    fileList = result['Value']
pprint.pprint(fileList)
exit(0)
Ejemplo n.º 4
0
from DIRAC.Core.Base import Script

Script.setUsageMessage(__doc__)

args = Script.getPositionalArgs()
#print len(args)
if len(args) < 3:
    Script.showHelp()
    exit(-1)

datasetName = args[0]
path = args[1]
strArg = args[2]

from IHEPDIRAC.Badger.API.Badger import Badger

badger = Badger()
prefix = badger.getDatasetNamePrefix()
datasetName = prefix + datasetName

#print datasetName
result = badger.registerDataset(datasetName, path, strArg)
if result['OK']:
    resVal = badger.getFilesByDatasetName(datasetName)
    if resVal['OK']:
        fileList = resVal['Value']
        badger.reCalcCount(fileList)
#print result

exit(0)