Example #1
0
def doMake():
    hasLib = os.path.isdir(glob.libDirName)
    hasExe = os.path.isfile(glob.exeName)
    isClean = glob.pars["clean"]
    isMake = glob.pars["make"] or (not hasLib) or (not hasExe)

    if isClean or isMake:
        resetDir(glob.libDirName, isClean)
    if isMake:
        log.info(
            blue(" - Moving to ") + red(glob.libDirName) +
            blue(" and compiling ANNZ... "))
        mkfl = os.path.join(glob.annzDir, 'Makefile')
        cmnd = "cd " + glob.libDirName + " ; make " + glob.makeOpt + " -f " + mkfl
        cmkdStatus = os.system(cmnd)
        Assert("compilation failed", (cmkdStatus == 0))

        if os.path.isfile(glob.exeName):
            log.info(
                blue(" - Found ") + red(glob.exeName) +
                blue(" - compilation seems to have succeded... "))

    # check that the executable exists before moving on and add the lib dir to LD_LIBRARY_PATH (needed on some systems)
    if not isClean:
        Assert("Did not find ANNZ executable (" + glob.exeName + ")",
               os.path.isfile(glob.exeName))

    if not glob.libDirName in os.environ["LD_LIBRARY_PATH"]:
        if os.environ["LD_LIBRARY_PATH"] == "":
            os.environ["LD_LIBRARY_PATH"] = glob.libDirName
        else:
            os.environ["LD_LIBRARY_PATH"] = glob.libDirName + ":" + os.environ[
                "LD_LIBRARY_PATH"]

    if glob.pars["onlyMake"]: exit(0)
Example #2
0
def resetDir(dirName, resetOutDir, verb=True):
    Assert("Tried to resetDir with empty directory name", dirName != "")
    if verb:
        log.info(
            blue(" - Resetting directory(") + yellow(dirName) + blue(",") +
            red(resetOutDir) + blue(")"))

    if os.path.isdir(dirName):
        if resetOutDir:
            filesInDir = os.listdir(dirName)
            for fileNow in filesInDir:
                os.system("rm -v " + dirName + "/" + fileNow)
    else:
        os.system("mkdir -vp  " + dirName)
Example #3
0
def runOneANNZ():
    cmnd = glob.exeName + " "
    cmndPrint = ""
    for key in glob.annz:
        if key == "":
            continue
        elif key == "generalOpt":
            cmnd += str(glob.annz[key]) + " "
            cmndPrint += blue(str(glob.annz[key])) + " , "
        else:
            cmnd += key + "=" + "\'" + str(glob.annz[key]) + "\' "
            cmndPrint += blue(str(key)) + red(str("=")) + "\'" + green(
                str(glob.annz[key])) + "\' , "

    if glob.pars["logFileName"] != "":
        cmnd += " > " + glob.pars["logFileName"] + "_annz 2>&1"
        cmndPrint += purple(" > " + glob.pars["logFileName"] + "_annz 2>&1")

    log.info(
        yellow(" - Will run " + glob.exeName +
               " with the following user-options: "))
    log.info("   " + cmndPrint)
    log.info("")

    return os.system(cmnd)
Example #4
0
def initROOT():

    if "ROOTSYS" in os.environ and glob.useDefinedROOTSYS:
        log.info(
            blue(" - Found defined ") + green("ROOTSYS") + blue(" = \"") +
            yellow(os.environ["ROOTSYS"]) +
            blue("\". Setting glob.rootHome to match"))
        glob.rootHome = os.environ["ROOTSYS"]

    rootExeDir = glob.rootHome + "/bin/"
    rootExe = rootExeDir + "/root"
    rootHomeLib = glob.rootHome + "/lib/"

    Assert("Found rootHome = "+glob.rootHome+" which does not exist... Please set this in commonImports.py to the" \
           +" ROOT installation directory !",os.path.isdir(glob.rootHome))

    Assert("Did not find ROOT executable, expected as "+rootExe+"  ..." \
           +" Is ROOT properly installed ? Is glob.rootHome set to match ?",os.path.isfile(rootExe))

    # add the bin directory of ROOT as first in the PATH, to make sure that the correct bin/root-config is used in the Makefile
    os.environ["PATH"] = rootExeDir + ":" + os.environ["PATH"]

    if not "ROOTSYS" in os.environ:
        os.environ["ROOTSYS"] = glob.rootHome
        log.info(
            blue(" - Setting ") + green("ROOTSYS") + blue(" = \"") +
            yellow(os.environ["ROOTSYS"]) + blue("\""))

    elif glob.rootHome != os.environ["ROOTSYS"]:
        os.environ["ROOTSYS"] = glob.rootHome
        log.info(
            blue(" - Setting ") + green("ROOTSYS") + blue(" = \"") +
            yellow(os.environ["ROOTSYS"]) + blue("\""))

    else:
        log.info(
            blue(" - Will use ") + green("ROOTSYS") + blue(" = \"") +
            yellow(os.environ["ROOTSYS"]) + blue("\""))

    if not "LD_LIBRARY_PATH" in os.environ:
        os.environ["LD_LIBRARY_PATH"] = rootHomeLib
        log.info(
            blue(" - Setting ") + green("LD_LIBRARY_PATH") + blue(" = \"") +
            yellow(os.environ["LD_LIBRARY_PATH"]) + blue("\""))

    elif not (rootHomeLib) in os.environ["LD_LIBRARY_PATH"]:
        os.environ["LD_LIBRARY_PATH"] = rootHomeLib + ":" + os.environ[
            "LD_LIBRARY_PATH"]
        log.info(
            blue(" - Adding to ") + green("LD_LIBRARY_PATH") + blue(" \"") +
            yellow(rootHomeLib) + blue("\""))

    else:
        log.info(
            blue(" - Found ") + green("LD_LIBRARY_PATH") + blue(" = \"") +
            yellow(os.environ["LD_LIBRARY_PATH"]) + blue("\""))

    return