Exemplo n.º 1
0
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))
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
def getDefaultConfig():
    global _defaultConfig
    if _defaultConfig is None:
        _defaultConfig = DOUGConfigParser(name="DOUG default config")
        _defaultConfig.addConfigContents(doug.execution_conf_tmpl)
    return _defaultConfig
Exemplo n.º 4
0
    def _solve(self, initialConfig, problemArchive):
        try:
            config = DOUGConfigParser(name='DOUG execution parameters')
            config.addConfigContents(doug.execution.getDefaultConfigContents())
            config.addConfig(initialConfig)
            
            suffix = time.strftime('--run-%y%m%d-%H%M%S')
            config.set('DEFAULT', 'doug-workdir', problemArchive.directoryName+suffix)
            config.set('DEFAULT', 'doug-datadir', problemArchive.directoryName)

            matrixFiles = problemArchive.getFiles('Matrix')
            if matrixFiles:
                matrixFile='%(doug-datadir)s/'+matrixFiles[0]
            else:
                matrixFile=''
            config.set('doug-controls', 'assembled_mtx_file', matrixFile)
                           
            rhsFiles = problemArchive.getFiles('Vector/RHS')
            if rhsFiles:
                rhsFile='%(doug-datadir)s/'+rhsFiles[0]
            else:
                rhsFile=''
            config.set('doug-controls', 'assembled_rhs_file', rhsFile)

            # change configurations
            configPanel = ConfigPanel(self.frame, config, title="DOUG configuration",
                                      sectionNames=['DEFAULT', 'doug', 'doug-controls'])
            if not configPanel.done:
                return
            
            # run            
            execution = doug.execution.DOUGExecution(config)
            try:
                archive = Archive(problemArchive.name+suffix,
                                  directoryName=problemArchive.directoryName+suffix,
                                  archiveType='solution')
                archive.info.set('general','problem-name',problemArchive.name)
                archive.info.addConfig(execution.config)

                archive.info.set('doug-execution', 'date', time.strftime('%y-%m-%d %H:%M:%S'), addsection=True)
                
                resultConfig=execution.run()
                archive.info.addConfig(resultConfig)

                if archive.info.has_option('doug-result', 'solutionfile'):
                    archive.setFileType(archive.info.get('doug-result', 'solutionfile'), 'Vector/Solution')
                if archive.info.has_option('doug-result', 'errorfile'):
                    archive.setFileType(archive.info.get('doug-result', 'errorfile'), 'Text/Error')
                if archive.info.has_option('doug-result', 'outputfile'):
                    archive.setFileType(archive.info.get('doug-result', 'outputfile'), 'Text/Output')
                if archive.info.has_option('doug-result', 'fineaggrsfile'):
                    archive.setFileType(archive.info.get('doug-result', 'fineaggrsfile'), 'Aggregates/Fine')
                if archive.info.has_option('doug-result', 'coarseaggrsfile'):
                    archive.setFileType(archive.info.get('doug-result', 'coarseaggrsfile'), 'Aggregates/Coarse')
                if archive.info.has_option('doug-result', 'profilefile'):
                    archive.setFileType(archive.info.get('doug-result', 'profilefile'), 'Text/Profile')
                    
            finally:
                self.app.addArchive(archive)
        except(Exception), e:
            LOG.error(e, exc_info=e)
Exemplo n.º 5
0
class App:
    def __reload(self, ev):
        import doug.execution
        print "Reloading execution"
        reload(doug.execution)
    
    def __init__(self, root):
        self.root = root
        root.title('DOUG execution manager')
        root.geometry('800x600')
        self.problemsArchives = []
        self.solutionsArchives = []
        self.__loadOptions()

        root.protocol('WM_DELETE_WINDOW', self.__closeApp)
        root.bind('<Control-R>', self.__reload)
        
        bottomFrame = Frame(root)
        bottomFrame.pack(side=BOTTOM, fill=X)

        menubar = Menu(root)
        root.config(menu=menubar)

        # main frame
        mainFrame=Pmw.NoteBook(root)
        self.notebook=mainFrame
        mainFrame.pack(expand=True, fill=BOTH)
        
        problemsFrame = LabelFrame(mainFrame.add('problems'), text='Problems', fg='blue')
        problemsFrame.pack(side=TOP, expand=True, fill=BOTH)
        solutionsFrame = LabelFrame(mainFrame.add('solutions'), text='Solutions', fg='blue')
        solutionsFrame.pack(side=TOP, expand=True, fill=BOTH)
        resultsFrame = LabelFrame(mainFrame.add('results'), text='Results', fg='blue')
        resultsFrame.pack(side=TOP, expand=True, fill=BOTH)

        # problems listbox
        self.problemPanel = ProblemArchivePanel(problemsFrame, self.config, self)

        listbox = ArchiveListbox(problemsFrame,
                                 archiveList=self.problemsArchives,
                                 archivePanel=self.problemPanel)

        self.problemsListbox = listbox
        listbox.pack(side=LEFT, fill=Y)

        self.problemPanel.frame.pack(side=TOP, expand=True, fill=BOTH)

        addb = Button(problemsFrame, text="Add archive", command=self.__addArchive)
        addb.pack(side=TOP)

        # solutions listbox
        self.solutionPanel = SolutionArchivePanel(solutionsFrame, self.config, self)

        listbox = ArchiveListbox(solutionsFrame,
                                 archiveList=self.solutionsArchives,
                                 archivePanel=self.solutionPanel)
        self.solutionsListbox = listbox
        listbox.pack(side=LEFT, fill=Y)

        self.solutionPanel.frame.pack(side=TOP, expand=True, fill=BOTH)

        menu = Menu(menubar, tearoff=False)
        menu.add_command(label='Quit', command=self.__closeApp)
        menubar.add_cascade(label='File', menu=menu)

        menu = Menu(menubar, tearoff=False)
        menu.add_command(label='Options', command=self.__editOptions)
        menubar.add_cascade(label='Tools', menu=menu)

        self.__scanDirectory('.', {
            'problem': (self.problemsArchives, self.problemsListbox),
            'solution': (self.solutionsArchives, self.solutionsListbox)})

        # results frame
        resultTable = ResultTable(self, resultsFrame)
        refreshB = Button(resultsFrame, text='refresh', fg="green", command=resultTable.refresh)
        refreshB.pack(anchor=W)
        resultTable.frame.pack(fill=BOTH, expand=True)

    def __editOptions(self):
        d = ConfigPanel(self.root, self.config, title='Global options')
        if d.done:
            self.__saveOptions()

    def __scanDirectory(self, dirpath, archiveTypes):
        dirs = os.listdir(dirpath)
        dirs = map(lambda x: os.path.join(dirpath, x), dirs) # create full paths
        dirs = filter(os.path.isdir, dirs) # filter directories
        
        for subdir in dirs:
            if os.path.exists(os.path.join(subdir, '.info')):
                abssubdir = os.path.abspath(subdir)
                archive = Archive(directoryName = abssubdir)
                t = archive.info.get('general', 'archive-type')
                if t in archiveTypes:
                    archiveTypes[t][0].append(archive)
                    archiveTypes[t][1].insert(END, archive.name)

    def addArchive(self, archive):
        archiveType = archive.info.get('general', 'archive-type')
        if archiveType=='problem':
            self.problemsArchives.append(archive)
            self.problemsListbox.insert(END, archive.name)
            self.notebook.selectpage('problems')
            self.problemsListbox.focus()
        elif archiveType=='solution':
            self.solutionsArchives.append(archive)
            self.notebook.selectpage('solutions')
            self.solutionsListbox.focus()
            self.solutionsListbox.insert(END, archive.name)
            self.solutionsListbox.setvalue(archive.name)
            
    def __addArchive(self):
        name = tkSimpleDialog.askstring("Insert name", "Type new archive name (without .tar.gz)")
        if name:
            archive = Archive(name)
            self.addArchive(archive)

    def __closeApp(self):
        for archive in self.problemsArchives:
            archive.close()
        for archive in self.solutionsArchives:
            archive.close()
        LOG.info("Closing application")
        self.root.destroy()

    def __loadOptions(self):
        self.config = DOUGConfigParser()
        self.config.addConfigContents(_configContent)
        if os.path.exists('.manager.conf'):
            self.config.read('.manager.conf')

    def __saveOptions(self):
        f = open('.manager.conf', 'w')
        try:
            LOG.info('Saving %s' % f)
            self.config.write(f)
        finally:
            f.close()

    def getProblemArchive(self, name):
        for archive in self.problemsArchives:
            if archive.name==name:
                return archive
        return None