Beispiel #1
0
 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()
Beispiel #2
0
 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}  
Beispiel #3
0
def castorBaseDir(user=os.environ['USER'], area=None):
    """Gets the top level directory to use for writing for 'user'"""

    if area is None:
        user, area = getUserAndArea(user)

    d = '/store/cmst3/%s/%s/CMG' % (area, user)
    exists = castortools.fileExists(castortools.lfnToCastor(d))
    if exists:
        return d
    else:
        print 'directory', d, 'does not exist. Are you sure about the username?'
        raise NameError(d)
Beispiel #4
0
#!/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
Beispiel #5
0
                  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)