def _plot(self, gridFile, solutionFile=None, aggregatesFile=None, connectionsFile=None): config = DOUGConfigParser(name='Plot parameters') config.addConfig(self.app.config) configPanel = ConfigPanel(self.app.root, config, title="Plot configuration", sectionNames=['gridplot']) if not configPanel.done: return LOG.info("Show plot of %s", gridFile) gridplot=os.path.join(os.path.dirname(sys.argv[0]), 'gridplot.py') args = [gridplot, gridplot] args.extend(['--gin', gridFile]) if solutionFile: args.extend(['--sin', solutionFile]) if aggregatesFile: args.extend(['--ain', aggregatesFile]) if connectionsFile: args.extend(['--cin', connectionsFile]) plargs=[] device=config.get('gridplot', 'device') plargs.extend(['-dev', device]) aggr=config.get('gridplot', 'aggr', None) if aggr: args.extend(['--aggr', aggr]) args.extend(['--plplot', " ".join(plargs)]) LOG.debug("Spawn '%s'", args) os.spawnvp(os.P_NOWAIT, 'python', args)
def createTestRun(): gconfFile = tarFile.extractfile(testtar.GLOBAL_CONF) gconfContent = gconfFile.read() config = DOUGConfigParser() config.addConfigContents(gconfContent) startTime = float(config.get("testrun", "starttime")) stopTime = float(config.get("testrun", "stoptime")) store.insertTestRun(config, datetime.fromtimestamp(startTime)) store.updateTestRunStop(datetime.fromtimestamp(stopTime))
def load(self): LOG.info("Loading from %s" % self.directoryName) config = DOUGConfigParser() config.read([os.path.join(self.directoryName, '.info')]) self.info = config if config.has_section('general'): self.name = config.get('general', 'name') else: config.add_section('general') if config.has_section('files'): types = config.get('files', 'types', default="") types = types.split(",") types = filter(bool, types) # filter out empty strings types = map(lambda s: map(str.strip, s.split(':')), types) for filename, filetype in types: self.setFileType(filename, filetype) else: config.add_section('files')
def createTest(testdir, members): del members[testtar.TEST_CONF] testConfigFile = tarFile.extractfile("/".join([testdir.name, testtar.TEST_CONF])) testConfigContent = testConfigFile.read() del members[testtar.RESULT_CONF] testResultFile = tarFile.extractfile("/".join([testdir.name, testtar.RESULT_CONF])) testResultContent = testResultFile.read() config = DOUGConfigParser() config.addConfigContents(testConfigContent) config.addConfigContents(testResultContent) # store test times and status testname = config.get("test", "name") startTime = float(config.get("test", "starttime")) stopTime = float(config.get("test", "stoptime")) ID = store.insertTest(testname, datetime.fromtimestamp(startTime), config) store.updateTestStop(ID, datetime.fromtimestamp(stopTime)) status = config.get("doug-result", "status").upper() status = testmysql.TestStatus.STRS.index(status) store.updateTestStatus(ID, status) # store error if members.has_key(testtar.EXCEPTION_FILE): del members[testtar.EXCEPTION_FILE] exceptionFile = tarFile.extractfile("/".join([testdir.name, testtar.EXCEPTION_FILE])) exc = pickle.load(exceptionFile) store.updateTestError(ID, str(exc)) # store profile info if config.has_section('doug-profile'): store.updateTestProfileInfo(ID, config) # left files should be stored to database for name in members.keys(): file = tarFile.extractfile("/".join([testdir.name, name])) fileContent = file.read() store.insertTestFileContent(ID, name, fileContent)
sys.exit(1) if len(extra)>0: usage() sys.exit(1) confFileNames = [] for opt in opts: if opt[0]=="--conf": confFileNames.append(opt[1]) # config and tar file conf = DOUGConfigParser() conf.read(confFileNames) host = conf.get("testscript", "mysql-host") user = conf.get("testscript", "mysql-user") password = conf.get("testscript", "mysql-password") database = conf.get("testscript", "mysql-database") class TestResult: def __init__(self, **kvargs): self.__dict__.update(kvargs) def __str__(self): return "TestResult(ID=%d)"%self.ID def getKeyHeader(self): return ('name','inputtype','solver','method','levels','overlap','smoothers','nproc') def getKey(self):
class DOUGExecution: def __init__(self, config, dougControls=None): self.workdir = os.path.abspath(config.get('doug', 'workdir')) self.config = DOUGConfigParser(name='DOUG execution', basedir=self.workdir) # default config self.config.addConfig(getDefaultConfig()) self.config.addControlFile(getDefaultControlFile(self.workdir)) # copy controls from control file if dougControls is not None: self.config.addControlFile(dougControls) # copy config self.config.addConfig(config) # output or other files, exception grabs it on exit self.files = [] # how many test results are using this test, files are deleted only after last free() call self._inUse = 0 self.preserveOutput = self.config.getboolean("doug", "preserveOutput") self.result = DOUGConfigParser(self.config.defaults(), basedir=self.workdir) self.result.add_section('doug-result') def setUp(self): LOG.debug("Preparing testing environment") self.workdir = self.workdir if os.path.isdir(self.workdir): self.workdirExisted = True else: self.workdirExisted = False os.mkdir(self.workdir) LOG.debug("Working directory %s created" % self.workdir) try: # create control file self.testctrlfname = os.path.abspath(os.path.join(self.workdir, 'DOUG-exec.ctl')) controlFile = self.config.getControlFile(self.testctrlfname) controlFile.save(self.testctrlfname) self.files.append((self.testctrlfname, "Control file")) # run mpiboot mpibootname = self.config.get("doug", "mpiboot") outfilename = self.config.get("doug", "mpiboot-outfilename") errfilename = self.config.get("doug", "mpiboot-errfilename") if mpibootname: LOG.debug("Setting up mpi") mpiboot = subprocess.Popen("%s > %s 2> %s" % (mpibootname, outfilename, errfilename), shell=True) res = mpiboot.wait() if res: raise ScriptException("Error running %s (%d)" "inspect output files (%s, %s) for error description." % (mpibootname, res, outfilename, errfilename)) except: self._clean() raise def tearDown(self): try: mpihaltname = self.config.get("doug", "mpihalt") if mpihaltname: outfilename = self.config.get("doug", "mpihalt-outfilename") errfilename = self.config.get("doug", "mpihalt-errfilename") LOG.debug("Shutting down mpi") mpihalt = subprocess.Popen("%s > %s 2> %s" % (mpihaltname, outfilename, errfilename), shell=True) import time time.sleep(4) # lamhalt <=7.1.1 does not wait until whole universe is shut down res = mpihalt.wait() if res: LOG.warn("Error running %s (%d)" "inspect output files (%s, %s) for error description." % (mpihaltname, res, outfilename, errfilename)) except Exception, e: LOG.warn("Exception running mpihalt: %s" % e)