コード例 #1
0
ファイル: batchmanager.py プロジェクト: vmariani/heppy
 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
             import eostools as castortools
             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.'
                     ]))
     self.remoteOutputFile_ = ""
     return (self.options_, self.args_)
コード例 #2
0
ファイル: batchmanager.py プロジェクト: Andrej-CMS/cmssw
    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_)
コード例 #3
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
コード例 #4
0
ファイル: logger.py プロジェクト: Andrej-CMS/cmssw
 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
コード例 #5
0
ファイル: logger.py プロジェクト: UVa-IHEP/cmg-cmssw
    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'
コード例 #6
0
ファイル: logger.py プロジェクト: Andrej-CMS/cmssw
    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'