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)
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)
def runOneANNZ(): cmnd = glob.exeName+" " ; cmndPrint = "" for key in glob.annz: if key == "": continue if key == "generalOpt": cmnd += str(glob.annz[key])+" " ; cmndPrint += blue(str(glob.annz[key]))+" , " 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)