def prepProcDir(param,baseDir,targetDir=None): if targetDir!=None: procPath=targetDir else: procPath=os.path.join(baseDir,param.targetDir) if os.path.exists(procPath): try: shutil.rmtree(procPath) except: print "Process Directory %s exists. Having trouble removing it"%procPath os.mkdir(procPath,0777) param.write2file(procPath) return os.path.abspath(procPath)
def genRunModel(param,origSpec,basePath): currentNode=pyfica.launcher2.getNodeName() fica_bin=pyfica.launcher2.machineConf[currentNode]['fica_bin'] ficaWorkDir=os.path.join(basePath,param.targetDir) try: os.makedirs(ficaWorkDir) except: shutil.rmtree(ficaWorkDir) os.makedirs(ficaWorkDir) param.write2file(ficaWorkDir) #print "Running %s on %s in dir %s"%(fica_bin,currentNode,ficaWorkDir) proc=subprocess.Popen([fica_bin],stdout=-1,cwd=ficaWorkDir,close_fds=True) #Saving Log File: file(os.path.join(ficaWorkDir,'fica.log'),'w').write(proc.stdout.read()) proc.stdout.close() #print "tested %s"%proc.stdout.read() #return "I have run %s on %s"%(basePath,getNodeName()) model=pyfica.read.model(param,ficaWorkDir,origSpec) model.fitness=fitFunc(model) return model