예제 #1
0
 def ParseOptions(self):       
     (self.options_,self.args_) = self.parser_.parse_args()
     if self.options_.remoteCopy == None:
         self.remoteOutputDir_ = ""
     else:
         # removing possible trailing slash
         self.remoteOutputDir_ = self.options_.remoteCopy.rstrip('/')
         if not castortools.isLFN( self.remoteOutputDir_ ):
             print 'When providing an output directory, you must give its LFN, starting by /store. You gave:'
             print self.remoteOutputDir_
             sys.exit(1)          
         self.remoteOutputDir_ = castortools.lfnToEOS( self.remoteOutputDir_ )
         dirExist = castortools.isDirectory( self.remoteOutputDir_ )           
         # nsls = 'nsls %s > /dev/null' % self.remoteOutputDir_
         # dirExist = os.system( nsls )
         if dirExist is False:
             print 'creating ', self.remoteOutputDir_
             if castortools.isEOSFile( self.remoteOutputDir_ ):
                 # the output directory is currently a file..
                 # need to remove it.
                 castortools.rm( self.remoteOutputDir_ )
             castortools.createEOSDir( self.remoteOutputDir_ )
         else:
             # directory exists.
             if self.options_.negate is False and self.options_.force is False:
                 #COLIN need to reimplement protectedRemove in eostools
                 raise ValueError(  ' '.join(['directory ', self.remoteOutputDir_, ' already exists.']))
                 # if not castortools.protectedRemove( self.remoteOutputDir_, '.*root'):
                 # the user does not want to delete the root files                          
     self.remoteOutputFile_ = ""
     self.ManageOutputDir()
     return (self.options_, self.args_)
예제 #2
0
    def ParseOptions(self):
        (self.options_, self.args_) = self.parser_.parse_args()
        if self.options_.remoteCopy == None:
            self.remoteOutputDir_ = ""
        else:
            # removing possible trailing slash
            import CMGTools.Production.eostools as castortools
            self.remoteOutputDir_ = self.options_.remoteCopy.rstrip('/')

            if "psi.ch" in self.remoteOutputDir_:  # T3 @ PSI:
                # overwriting protection to be improved
                if self.remoteOutputDir_.startswith("/pnfs/psi.ch"):
                    os.system("gfal-mkdir srm://t3se01.psi.ch/" +
                              self.remoteOutputDir_)
                    outputDir = self.options_.outputDir
                    if outputDir == None:
                        today = datetime.today()
                        outputDir = 'OutCmsBatch_%s' % today.strftime(
                            "%d%h%y_%H%M")
                    self.remoteOutputDir_ += "/" + outputDir
                    os.system("gfal-mkdir srm://t3se01.psi.ch/" +
                              self.remoteOutputDir_)
                else:
                    print "remote directory must start with /pnfs/psi.ch to send to the tier3 at PSI"
                    print self.remoteOutputDir_, "not valid"
                    sys.exit(1)
            else:  # assume EOS
                if not castortools.isLFN(self.remoteOutputDir_):
                    print 'When providing an output directory, you must give its LFN, starting by /store. You gave:'
                    print self.remoteOutputDir_
                    sys.exit(1)
                self.remoteOutputDir_ = castortools.lfnToEOS(
                    self.remoteOutputDir_)
                dirExist = castortools.isDirectory(self.remoteOutputDir_)
                # nsls = 'nsls %s > /dev/null' % self.remoteOutputDir_
                # dirExist = os.system( nsls )
                if dirExist is False:
                    print 'creating ', self.remoteOutputDir_
                    if castortools.isEOSFile(self.remoteOutputDir_):
                        # the output directory is currently a file..
                        # need to remove it.
                        castortools.rm(self.remoteOutputDir_)
                    castortools.createEOSDir(self.remoteOutputDir_)
                else:
                    # directory exists.
                    if self.options_.negate is False and self.options_.force is False:
                        #COLIN need to reimplement protectedRemove in eostools
                        raise ValueError(' '.join([
                            'directory ', self.remoteOutputDir_,
                            ' already exists.'
                        ]))
                        # if not castortools.protectedRemove( self.remoteOutputDir_, '.*root'):
                        # the user does not want to delete the root files
        self.remoteOutputFile_ = ""
        self.ManageOutputDir()
        return (self.options_, self.args_)
예제 #3
0
    def ParseOptions(self):
        (self.options_, self.args_) = self.parser_.parse_args()
        if self.options_.remoteCopy == None:
            self.remoteOutputDir_ = ""
        else:
            # removing possible trailing slash
            self.remoteOutputDir_ = self.options_.remoteCopy.rstrip("/")
            if "psi.ch" in self.remoteOutputDir_:  # T3 @ PSI:
                # overwriting protection to be improved
                if self.remoteOutputDir_.startswith("/pnfs/psi.ch"):
                    ld_lib_path = os.environ.get("LD_LIBRARY_PATH")
                    if ld_lib_path != "None":
                        os.environ["LD_LIBRARY_PATH"] = (
                            "/usr/lib64/:" + ld_lib_path
                        )  # to solve gfal conflict with CMSSW
                    os.system("gfal-mkdir srm://t3se01.psi.ch/" + self.remoteOutputDir_)
                    outputDir = self.options_.outputDir
                    if outputDir == None:
                        today = datetime.today()
                        outputDir = "OutCmsBatch_%s" % today.strftime("%d%h%y_%H%M")
                    self.remoteOutputDir_ += "/" + outputDir
                    os.system("gfal-mkdir srm://t3se01.psi.ch/" + self.remoteOutputDir_)
                    if ld_lib_path != "None":
                        os.environ["LD_LIBRARY_PATH"] = ld_lib_path  # back to original to avoid conflicts
                else:
                    print "remote directory must start with /pnfs/psi.ch to send to the tier3 at PSI"
                    print self.remoteOutputDir_, "not valid"
                    sys.exit(1)
            else:  # assume EOS
                if not castortools.isLFN(self.remoteOutputDir_):
                    print "When providing an output directory, you must give its LFN, starting by /store. You gave:"
                    print self.remoteOutputDir_
                    sys.exit(1)
                self.remoteOutputDir_ = castortools.lfnToEOS(self.remoteOutputDir_)
                dirExist = castortools.isDirectory(self.remoteOutputDir_)
                # nsls = 'nsls %s > /dev/null' % self.remoteOutputDir_
                # dirExist = os.system( nsls )
                if dirExist is False:
                    print "creating ", self.remoteOutputDir_
                    if castortools.isEOSFile(self.remoteOutputDir_):
                        # the output directory is currently a file..
                        # need to remove it.
                        castortools.rm(self.remoteOutputDir_)
                    castortools.createEOSDir(self.remoteOutputDir_)
                else:
                    # directory exists.
                    if self.options_.negate is False and self.options_.force is False:
                        # COLIN need to reimplement protectedRemove in eostools
                        raise ValueError(" ".join(["directory ", self.remoteOutputDir_, " already exists."]))
                    # if not castortools.protectedRemove( self.remoteOutputDir_, '.*root'):
                    # the user does not want to delete the root files

        self.remoteOutputFile_ = ""
        self.ManageOutputDir()
        return (self.options_, self.args_)
예제 #4
0
 def ParseOptions(self):     
     (self.options_,self.args_) = self.parser_.parse_args()
     if self.options_.remoteCopy == None:
         self.remoteOutputDir_ = ""
     else: 
         # removing possible trailing slash
         import CMGTools.Production.eostools as castortools
         self.remoteOutputDir_ = self.options_.remoteCopy.rstrip('/')
 
         if "psi.ch" in self.remoteOutputDir_: # T3 @ PSI:
             # overwriting protection to be improved
             if self.remoteOutputDir_.startswith("/pnfs/psi.ch"):
                 os.system("gfal-mkdir srm://t3se01.psi.ch/"+self.remoteOutputDir_)
                 outputDir = self.options_.outputDir
                 if outputDir==None:
                     today = datetime.today()
                     outputDir = 'OutCmsBatch_%s' % today.strftime("%d%h%y_%H%M")
                 self.remoteOutputDir_+="/"+outputDir
                 os.system("gfal-mkdir srm://t3se01.psi.ch/"+self.remoteOutputDir_)
             else:
                 print "remote directory must start with /pnfs/psi.ch to send to the tier3 at PSI"
                 print self.remoteOutputDir_, "not valid"
                 sys.exit(1)
         else: # assume EOS
             if not castortools.isLFN( self.remoteOutputDir_ ):
                 print 'When providing an output directory, you must give its LFN, starting by /store. You gave:'
                 print self.remoteOutputDir_
                 sys.exit(1)          
             self.remoteOutputDir_ = castortools.lfnToEOS( self.remoteOutputDir_ )
             dirExist = castortools.isDirectory( self.remoteOutputDir_ )           
             # nsls = 'nsls %s > /dev/null' % self.remoteOutputDir_
             # dirExist = os.system( nsls )
             if dirExist is False:
                 print 'creating ', self.remoteOutputDir_
                 if castortools.isEOSFile( self.remoteOutputDir_ ):
                     # the output directory is currently a file..
                     # need to remove it.
                     castortools.rm( self.remoteOutputDir_ )
                 castortools.createEOSDir( self.remoteOutputDir_ )
             else:
                 # directory exists.
                 if self.options_.negate is False and self.options_.force is False:
                     #COLIN need to reimplement protectedRemove in eostools
                     raise ValueError(  ' '.join(['directory ', self.remoteOutputDir_, ' already exists.']))
                     # if not castortools.protectedRemove( self.remoteOutputDir_, '.*root'):
                     # the user does not want to delete the root files                          
     self.remoteOutputFile_ = ""
     self.ManageOutputDir()
     return (self.options_, self.args_)
예제 #5
0
    def buildDatasetSizeReport(self):
        """Get the dataset size for both the directory, 
        and the individual file groups"""
        
        if self.dataset_details['FileGroups'] is None:
            raise NameError( "ERROR: No file groups found" )
        self.dataset.extractFileSizes()
        self.dataset_details['DirectorySizeInTB'] = 0.0
        for group_name in self.dataset_details['FileGroups']:
            size_in_bytes = 0
            for file_name in self.dataset_details['FileGroups'][group_name]['Files']:
                size_in_bytes += int(self.dataset.filesAndSizes[eostools.lfnToEOS(file_name)])

            size_in_tb = float(size_in_bytes)/1000000000000
            self.dataset_details['FileGroups'][group_name]["SizeInTB"]=size_in_tb
            self.dataset_details['DirectorySizeInTB']+=size_in_tb
예제 #6
0
    def buildDatasetSizeReport(self):
        """Get the dataset size for both the directory, 
        and the individual file groups"""

        if self.dataset_details['FileGroups'] is None:
            raise NameError("ERROR: No file groups found")
        self.dataset.extractFileSizes()
        self.dataset_details['DirectorySizeInTB'] = 0.0
        for group_name in self.dataset_details['FileGroups']:
            size_in_bytes = 0
            for file_name in self.dataset_details['FileGroups'][group_name][
                    'Files']:
                size_in_bytes += int(
                    self.dataset.filesAndSizes[eostools.lfnToEOS(file_name)])

            size_in_tb = float(size_in_bytes) / 1000000000000
            self.dataset_details['FileGroups'][group_name][
                "SizeInTB"] = size_in_tb
            self.dataset_details['DirectorySizeInTB'] += size_in_tb
    # Allow no more than one argument
    if len(args) != 1:
        parser.print_help()
        sys.exit(1)

    # For multiple file input

    file = open(args[0], 'r')
    lines = file.readlines()
    for line in lines:
        line = re.sub("\s+", " ", line)
        fileown = line.split("%")[0].lstrip().rstrip()
        dataset = line.split("%")[1].lstrip().rstrip()
        files = []
        if re.search('group', fileown):
            castor = eostools.lfnToEOS(
                castorBaseDir.castorBaseDir(fileown)) + dataset
            castor2 = eostools.lfnToEOS(
                castorBaseDir.castorBaseDir(fileown.strip("_group"))) + dataset
        else:
            castor = eostools.lfnToEOS(
                castorBaseDir.castorBaseDir(fileown)) + dataset
            castor2 = eostools.lfnToEOS(
                castorBaseDir.castorBaseDir(fileown + "_group")) + dataset
        LFN = eostools.eosToLFN(castor)
        LFN2 = eostools.eosToLFN(castor2)

        if eostools.isDirectory(castor):
            files = burrow(LFN)

        elif eostools.isDirectory(castor2):
            files = burrow(LFN2)
예제 #8
0
        parser.print_help()
        sys.exit(1)
    
    
    
    # For multiple file input
    
    file = open(args[0], 'r')
    lines = file.readlines()
    for line in lines:
        line = re.sub("\s+", " ", line)	
        fileown = line.split("%")[0].lstrip().rstrip()
        dataset = line.split("%")[1].lstrip().rstrip()
        files = []
        if re.search('group',fileown):
            castor = eostools.lfnToEOS(castorBaseDir.castorBaseDir(fileown))+dataset
            castor2 = eostools.lfnToEOS(castorBaseDir.castorBaseDir(fileown.strip("_group")))+dataset
        else:
            castor = eostools.lfnToEOS(castorBaseDir.castorBaseDir(fileown))+dataset
            castor2 = eostools.lfnToEOS(castorBaseDir.castorBaseDir(fileown+"_group"))+dataset
        LFN = eostools.eosToLFN(castor)
        LFN2 = eostools.eosToLFN(castor2)

        if eostools.isDirectory(castor):
            files = burrow(LFN)
            
        elif eostools.isDirectory(castor2):
            files = burrow(LFN2)
            
        print dataset
        for i in files: print "\t"+i