def doStartupChecks():

    global doStartFromPAT

    log.output("********** Checking environment **********")

    log.output("--> Checking if you have a "+options.cmssw_ver+" release.")

    if (os.path.isdir(options.cmssw_ver)):
        log.output(" ---> Ok, the release is present!")
        cmd ='cd '+options.cmssw_ver+'; cmsenv'
        pExe = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
    else:
        log.output(" ---> ERROR: Please scram the proper release first! (Exiting)")
        dieOnError("Environment: resquested CMSSW version is not found in the working directory")

    log.output("--> Checking if "+options.cmssw_ver+" contains the TopTreeProducer package.")

    if (os.path.isdir(options.cmssw_ver+TopTreeProducerDir)):
        log.output(" ---> Ok, the "+TopTreeProducerDir+" directory exists!")
    else:
        log.output(" ---> ERROR: Please ensure that you have the TopTreeProducer package installed! (Exiting)")
        dieOnError("Environment: resquested CMSSW version does not contain the TopTreeProducer package")


    log.output("--> Checking if "+options.cmssw_ver+" contains the PatAlgos package.")

    if (os.path.isdir(options.cmssw_ver+PatDir)):
        log.output(" ---> Ok, the "+PatDir+" directory exists!")
    else:
        log.output(" ---> ERROR: Please ensure that you have the PatAlgos package installed! (Exiting)")
        dieOnError("Environment: resquested CMSSW version does not contain the PatAlgos package")


    log.output("--> Checking DBS to see wether the requested Dataset exists")

    if dbsInst == "":
        dbsMgr = DBSHandler("cms_dbs_prod_global");
    else:
        dbsMgr = DBSHandler(dbsInst);

    if doStartFromPAT:

        dbsMgr.setDBSInst("cms_dbs_ph_analysis_02")

    if not dbsMgr.datasetExists(options.dataset):
        log.output(" ---> ERROR: "+options.dataset+" was not found in DBS! (Exiting)")
        dieOnError("Dataset: DBS query for your dataset returned an empty set.")

    else:
        log.output(" ---> Ok, Dataset was found!")

    log.output("--> Checking status of CRABServer (not yet implemented)")

    crab = CRABHandler("","","",log)

    crab.checkGridProxy(False)

    crab.checkCredentials(False)
# toptree to remove

idTop = []
storagePathTop = []
mergedTopLocation = []

# logging

log = logHandler("")

# update grid-proxy for srm commands

crab = CRABHandler("","",log)

crab.checkGridProxy(False)



#rmSRMdir("/pnfs/iihe/cms/store/user/dhondt/QCD_Pt-20to30_EMEnriched_TuneZ2_7TeV-pythia6/Spring11-PU_S1_START311_V1G1-v1/29032011_213110/TOPTREE")

#sys.exit(1)

#### Remove DataSet -> ALL associated PatTuples -> All associated TopTrees

if not options.cleanup and not options.rmDataSet == "None":

    log.output("--> Removing dataset "+options.rmDataSet+" and all associated PATtuples and TopTrees")

    sql.createQuery("SELECT","datasets","id","name = '"+options.rmDataSet+"'")
# toptree to remove

idTop = []
storagePathTop = []
mergedTopLocation = []

# logging

log = logHandler("")

# update grid-proxy for srm commands

crab = CRABHandler("", "", log)

crab.checkGridProxy(False)

#rmSRMdir("/pnfs/iihe/cms/store/user/dhondt/QCD_Pt-20to30_EMEnriched_TuneZ2_7TeV-pythia6/Spring11-PU_S1_START311_V1G1-v1/29032011_213110/TOPTREE")

#sys.exit(1)

#### Remove DataSet -> ALL associated PatTuples -> All associated TopTrees

if not options.cleanup and not options.rmDataSet == "None":

    log.output("--> Removing dataset " + options.rmDataSet +
               " and all associated PATtuples and TopTrees")

    sql.createQuery("SELECT", "datasets", "id",
                    "name = '" + options.rmDataSet + "'")
Example #4
0
# create a CrabHandler

crab = CRABHandler(timestamp, options.dir, log)

# change idle time

crab.idleTime = float(options.idleTime)
crab.idleTimeResubmit = float(options.idleTimeResubmit)

# set the crab env

crab.crabSource = "source /etc/profile.d/set_globus_tcp_port_range.sh; export EDG_WL_LOCATION=/opt/edg "

# check GRID proxy

crab.checkGridProxy(0)
crab.checkCredentials(0)

# check setup

toCheck = ["scram", "crab"]

for i in toCheck:
    log.output("--> Checking if you have " + i + " in your path")
    check = Popen("which " + i,
                  shell=True,
                  stdin=PIPE,
                  stdout=PIPE,
                  stderr=STDOUT,
                  close_fds=True).stdout.read()
# create a CrabHandler
    
crab = CRABHandler(timestamp,options.dir,log)

# change idle time

crab.idleTime=float(options.idleTime)
crab.idleTimeResubmit=float(options.idleTimeResubmit)

# set the crab env

crab.crabSource = "source /etc/profile.d/set_globus_tcp_port_range.sh; export EDG_WL_LOCATION=/opt/edg "

# check GRID proxy

crab.checkGridProxy(0)
crab.checkCredentials(0)

# check setup

toCheck = ["scram","crab"]

for i in toCheck:
    log.output("--> Checking if you have "+i+" in your path")
    check = Popen("which "+i, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True).stdout.read()

    if not check.rfind("no "+i+" in") == -1:
        log.output(" ---> ERROR:  you don't have "+i+" in your path, did you read the twiki instructions?")

        if options.stdout:
            print "Fatal ERROR, script exiting"
def doStartupChecks():

    global doStartFromPAT

    log.output("********** Checking environment **********")

    log.output("--> Checking if you have a " + options.cmssw_ver + " release.")

    if (os.path.isdir(options.cmssw_ver)):
        log.output(" ---> Ok, the release is present!")
        cmd = 'cd ' + options.cmssw_ver + '; cmsenv'
        pExe = Popen(cmd,
                     shell=True,
                     stdin=PIPE,
                     stdout=PIPE,
                     stderr=STDOUT,
                     close_fds=True)
    else:
        log.output(
            " ---> ERROR: Please scram the proper release first! (Exiting)")
        dieOnError(
            "Environment: resquested CMSSW version is not found in the working directory"
        )

    log.output("--> Checking if " + options.cmssw_ver +
               " contains the TopTreeProducer package.")

    if (os.path.isdir(options.cmssw_ver + TopTreeProducerDir)):
        log.output(" ---> Ok, the " + TopTreeProducerDir +
                   " directory exists!")
    else:
        log.output(
            " ---> ERROR: Please ensure that you have the TopTreeProducer package installed! (Exiting)"
        )
        dieOnError(
            "Environment: resquested CMSSW version does not contain the TopTreeProducer package"
        )

    log.output("--> Checking if " + options.cmssw_ver +
               " contains the PatAlgos package.")

    if (os.path.isdir(options.cmssw_ver + PatDir)):
        log.output(" ---> Ok, the " + PatDir + " directory exists!")
    else:
        log.output(
            " ---> ERROR: Please ensure that you have the PatAlgos package installed! (Exiting)"
        )
        dieOnError(
            "Environment: resquested CMSSW version does not contain the PatAlgos package"
        )

    log.output("--> Checking DBS to see wether the requested Dataset exists")

    if dbsInst == "":
        dbsMgr = DBSHandler("cms_dbs_prod_global")
    else:
        dbsMgr = DBSHandler(dbsInst)

    if doStartFromPAT:

        dbsMgr.setDBSInst("cms_dbs_ph_analysis_02")

    if not dbsMgr.datasetExists(options.dataset):
        log.output(" ---> ERROR: " + options.dataset +
                   " was not found in DBS! (Exiting)")
        dieOnError(
            "Dataset: DBS query for your dataset returned an empty set.")

    else:
        log.output(" ---> Ok, Dataset was found!")

    log.output("--> Checking status of CRABServer (not yet implemented)")

    crab = CRABHandler("", "", "", log)

    crab.checkGridProxy(False)

    crab.checkCredentials(False)