Example #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_)
Example #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_)
Example #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_)
Example #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_)