Exemplo n.º 1
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}  
Exemplo n.º 2
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)
Exemplo n.º 3
0
    def run(self, input):
        """Check that the directory is writable"""
        dir = input['FindOnCastor']['Directory']
        if self.options.check:
            
            _, name = tempfile.mkstemp('.txt',text=True)
            testFile = file(name,'w')
            testFile.write('Test file')
            testFile.close()

            store = castortools.castorToLFN(dir) 
            #this is bad, but castortools is giving me problems
            if not os.system('cmsStage %s %s' % (name,store)):
                fname = '%s/%s' % (dir,os.path.basename(name))
                write = castortools.fileExists(fname)
                if write:
                    castortools.rm(fname)
                else:
                    raise Exception("Failed to write to directory '%s'" % dir)
            os.remove(name)
        return {'Directory':dir,'WriteAccess':True}
Exemplo n.º 4
0
    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')
Exemplo n.º 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)
Exemplo n.º 6
0
 def isDirOnCastor(self, file):
     if castortools.fileExists(file):
         return True
     else:
         return False
Exemplo n.º 7
0
                  "--check",
                  dest="check",
                  default=False,
                  action='store_true',
                  help='Check filemask if available')

(options, args) = parser.parse_args()

if len(args) != 2:
    parser.print_help()
    sys.exit(1)

dir = args[0]
regexp = args[1]

exists = castortools.fileExists(dir)
if not exists:
    print 'sourceFileList: directory does not exist. Exiting'
    sys.exit(1)

files = castortools.matchingFiles(dir, regexp)

mask = "IntegrityCheck"
file_mask = []
if options.check:
    file_mask = castortools.matchingFiles(dir, '^%s_.*\.txt$' % mask)
bad_files = {}
if options.check and file_mask:
    from MaterialBudget.CMGTools.edmIntegrityCheck import PublishToFileSystem
    p = PublishToFileSystem(mask)
    report = p.get(dir)