urunnerclient

来自「数据挖掘方面的源码」· 代码 · 共 59 行

TXT
59
字号
import ConfigParser, string, JobQueue, os# get the parameterskHostName = string.split(os.uname()[1], '.')[0]config = ConfigParser.ConfigParser({"host":kHostName})config.read("config")queueFile  = os.path.abspath(config.get("GLOBAL", "queuefile"))lockDir   = os.path.abspath(config.get("GLOBAL", "lockdir"))scratchDir = os.path.abspath(config.get("GLOBAL", "scratchdir"))resultDir  = os.path.abspath(config.get("GLOBAL", "resultdir"))# set up the directoriesorigDir    = os.getcwd()toDelete = []tmpDir = scratchDirwhile not os.path.exists(tmpDir):   toDelete.append(tmpDir)   tmpDir = os.path.split(tmpDir)[0]if not os.path.exists(scratchDir):   os.makedirs(scratchDir)# should be done by uRunner Master, but just in case!if not os.path.exists(resultDir):   os.makedirs(resultDir)# set up the environmentos.environ['resultdir']  = resultDiros.environ['scratchdir'] = scratchDiros.environ['rundir']     = os.path.abspath(origDir)os.environ['host']       = kHostName# run the jobs while there are more of themqueue = JobQueue.JobQueue(queueFile, lockDir)finishedQueue = JobQueue.JobQueue(queueFile + ".finished", lockDir)job = queue.GetAndRemoveNextJob()while job != None:   # make the new directory and go to it   if not os.path.exists(scratchDir):      os.makedirs(scratchDir)   os.chdir(scratchDir)   # do the work   job.Run()   finishedQueue.AddJob(job)   job = queue.GetAndRemoveNextJob()   # clean up   os.chdir(origDir)   for d in toDelete:      os.system("rm -rf %s" % (d))

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?