Esempio n. 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_)
Esempio n. 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_)
Esempio n. 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_)
Esempio n. 4
0
 def isTgzDirOnEOS(self, file ):
     '''Checks if file is a .tgz file in an eos dir'''
     if not castortools.isCastorDir( file ):
         file = castortools.castorToLFN(file)
         
     if castortools.isLFN( file ):
         tgzPattern = re.compile('.*\.tgz$')
         m = tgzPattern.match( file )
         if m:
             return True
         else:
             return False
     else:
         return False
Esempio n. 5
0
    def isTgzDirOnCastor(self, file):

        if not castortools.isCastorDir(file):
            file = castortools.castorToLFN(file)

        if castortools.isLFN(file):
            tgzPattern = re.compile('.*\.tgz$')
            m = tgzPattern.match(file)
            if m:
                return True
            else:
                return False
        else:
            return False
Esempio n. 6
0
    def isTgzDirOnCastor(self, file ):

        if not castortools.isCastorDir( file ):
            file = castortools.castorToLFN(file)
            
        if castortools.isLFN( file ):
            tgzPattern = re.compile('.*\.tgz$')
            m = tgzPattern.match( file )
            if m:
                return True
            else:
                return False
        else:
            return False
Esempio n. 7
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_)
Esempio n. 8
0
    def stageOut(self, castorDir):

        castorDir = castortools.eosToLFN( castorDir )
        if not castortools.isLFN( castorDir ):
            print 'cannot stage out, you need to provide an LFN as a destination directory, beginning with /store .'
            return False
        
        if self.dirLocal != None:
            tgzDir = self.dirLocal + '.tgz'
            tgzCmd = 'tar -zcvf ' + tgzDir + ' ' + self.dirLocal
            print tgzCmd
            os.system( tgzCmd)
            cmsStage = 'cmsStage -f %s %s' % (tgzDir, castorDir )
            print cmsStage
            os.system( cmsStage )
            os.system('rm ' + tgzDir )
            self.tgzDirOnCastor =  castorDir + '/' + tgzDir
        else:
            print 'cannot stage out, the log is not staged in'
Esempio n. 9
0
    def stageOut(self, castorDir):

        castorDir = castortools.eosToLFN(castorDir)
        if not castortools.isLFN(castorDir):
            print "cannot stage out, you need to provide an LFN as a destination directory, beginning with /store ."
            return False

        if self.dirLocal != None:
            tgzDir = self.dirLocal + ".tgz"
            tgzCmd = "tar -zcvf " + tgzDir + " " + self.dirLocal
            print tgzCmd
            os.system(tgzCmd)
            cmsStage = "cmsStage -f %s %s" % (tgzDir, castorDir)
            print cmsStage
            os.system(cmsStage)
            os.system("rm " + tgzDir)
            self.tgzDirOnCastor = castorDir + "/" + tgzDir
        else:
            print "cannot stage out, the log is not staged in"