def __init__(self, user, name, pattern='.*root'): self.lfnDir = castorBaseDir(user) + name self.castorDir = castortools.lfnToCastor(self.lfnDir) super(Dataset, self).__init__(user, name, pattern) self.buildListOfFiles(pattern) self.extractFileSizes() self.buildListOfBadFiles()
def run(self, input): topdir = castortools.lfnToCastor(castorBaseDir(user=self.user)) directory = '%s/%s' % (topdir,self.dataset) directory = directory.replace('//','/') if not castortools.fileExists(directory): if hasattr(self,'create') and self.create: castortools.createCastorDir(directory) castortools.chmod(directory,'775') if not castortools.isDirectory(directory): raise Exception("Dataset directory '%s' does not exist or could not be created" % directory) return {'Topdir':topdir,'Directory':directory}
def __init__(self, setName, user): self._setName = setName.rstrip("/") self._user = user self._castor = None self._LFN = None self._tags = dict() self._release = None self._groups = [] self._integrity = None self._valid = False self._castorGroups = None castor = eostools.lfnToEOS( castorBaseDir.castorBaseDir(user)) + self._setName print castor # Check if local first (obviously) if os.path.isdir(setName) and user == os.environ['USER']: print "File is on local machine: " + local self._LFN = setName.lstrip("/") self._localTags() # Check if on castor next elif eostools.fileExists(castor + "/Logger.tgz"): print "File is directory on Castor" self._castor = castor self._LFN = eostools.eosToLFN(castor) self._castorTags() self._checkContiguity() # If logger is not present but directory exists elif eostools.isDirectory(castor): print "Directory is valid on Castor, but no logger file is present." self._castor = castor self._LFN = eostools.eosToLFN(castor) print self._LFN self._checkContiguity() # If neither then raise an exception else: raise ValueError( setName + ' is neither a tgz directory on castor or a local directory')
#!/usr/bin/env python import MaterialBudget.CMGTools.eostools as castortools from MaterialBudget.CMGTools.castorBaseDir import castorBaseDir if __name__ == '__main__': import sys from optparse import OptionParser parser = OptionParser() parser.usage = "%prog <user>\nPrints the castor base directory of a given user." parser.add_option( "-c", "--castorpath", action="store_true", dest="castorpath", help="Print full castor path. Otherwise print LFN, starting by /store", default=False) (options, args) = parser.parse_args() if len(args) != 1: parser.print_help() sys.exit(1) user = args[0] dir = castorBaseDir(user) if options.castorpath: dir = castortools.lfnToCastor(dir) print dir
dest="output", help="Output file name.", default="source_cff.py") (options, args) = parser.parse_args() if len(args) != 1: parser.print_help() sys.exit(1) sampleName = args[0].rstrip('/') # checking castor dir ----------------- import MaterialBudget.CMGTools.castorBaseDir as castorBaseDir cdir = castortools.lfnToCastor(castorBaseDir.castorBaseDir(options.user)) cdir += sampleName if not castortools.fileExists(cdir): print 'importNewSource: castor directory does not exist. Exit!' sys.exit(1) # sourceFileList = 'sourceFileList.py -c %s "%s" > %s' % (cdir, options.pattern, sourceFile) from MaterialBudget.CMGTools.doImportNewSource import doImportNewSource doImportNewSource(sampleName, 'sourceFileList.py -c %s "%s"' % (cdir, options.pattern), options.output)
if len(args)!=1: parser.print_help() sys.exit(1) sampleName = args[0] pattern = options.pattern # preparing castor dir ----------------- import MaterialBudget.CMGTools.castorBaseDir as castorBaseDir try: cdir = castorBaseDir.castorBaseDir( options.user ) except: print 'user does not have a castor base dir' sys.exit(1) cdir += sampleName if not castortools.fileExists( cdir ): print 'Directory ', cdir, 'does not exist' print 'Please check the sample name, and the user. You can specify a different user using the -u option' sys.exit(2) # making local source directory --------- ldir = "./"+sampleName