From 09d443bba27e603fed4fb6b3ffb1e0c77e4b8972 Mon Sep 17 00:00:00 2001 From: duplo Date: Mon, 5 Jan 2009 14:10:16 +0000 Subject: [PATCH] Improve the validation process, showing the results git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2132 38d2e660-2303-0410-9eaa-f027e97ec537 --- wizard/BToolchainPage.py | 46 +++++++++++++++++++++++++++------------- wizard/bertos_utils.py | 16 ++++++++++---- 2 files changed, 43 insertions(+), 19 deletions(-) diff --git a/wizard/BToolchainPage.py b/wizard/BToolchainPage.py index 202349a9..05b90d9c 100644 --- a/wizard/BToolchainPage.py +++ b/wizard/BToolchainPage.py @@ -47,11 +47,17 @@ class BToolchainPage(BWizardPage): def _search(self): dirList = [unicode(element.toString()) for element in self._settingsRetrieve("search_dir_list").toList()] - dirList += [element for element in bertos_utils.getSystemPath()] + if(self._settingsRetrieve("path_search").toBool()): + dirList += [element for element in bertos_utils.getSystemPath()] toolchainList = bertos_utils.findToolchains(dirList) + storedToolchainList = self._settingsRetrieve("toolchains").toList() + storedToolchainList = set([unicode(toolchain.toString()) for toolchain in storedToolchainList]) + toolchainList =set(toolchainList) - set(storedToolchainList) for element in toolchainList: - self.pageContent.toolchainList.addItem(QListWidgetItem(element)) - self._settingsStore("toolchains", toolchainList) + item = QListWidgetItem(element) + item.setData(Qt.UserRole, QVariant(element)) + self.pageContent.toolchainList.addItem(item) + self._settingsStore("toolchains", list(toolchainList.union(storedToolchainList))) def _connectSignals(self): self.connect(self.pageContent.toolchainList, SIGNAL("itemSelectionChanged()"), self._selectionChanged) @@ -60,6 +66,16 @@ class BToolchainPage(BWizardPage): self.connect(self.pageContent.searchButton, SIGNAL("clicked()"), self.searchToolchain) self.connect(self.pageContent.checkButton, SIGNAL("clicked()"), self.validateToolchains) + def _validItem(self, index, infos): + item = self.pageContent.toolchainList.item(index) + item.setIcon(QIcon(":/images/ok.png")) + item.setToolTip("Version: " + infos["version"] + "
Target: " + infos["target"] + + "
Thread model: " + infos["thread"]) + + def _invalidItem(self, index): + item = self.pageContent.toolchainList.item(index) + item.setIcon(QIcon(":/images/warning.png")) + def addToolchain(self): sel_toolchain = QFileDialog.getOpenFileName(self, self.tr("Choose the toolchain"), "") if not sel_toolchain.isEmpty(): @@ -75,7 +91,8 @@ class BToolchainPage(BWizardPage): item = self.pageContent.toolchainList.takeItem(self.pageContent.toolchainList.currentRow()) item = item.data(Qt.UserRole).toString() toolchains = self._settingsRetrieve("toolchains").toList() - toolchains = [toolchain.toString() for toolchain in toolchains] + toolchains = [unicode(toolchain.toString()) for toolchain in toolchains] + print unicode(item), type(unicode(item)) toolchains.remove(unicode(item)) self._settingsStore("toolchains", toolchains) @@ -85,22 +102,21 @@ class BToolchainPage(BWizardPage): search.exec_() def validateToolchains(self): - print "validating toolchains" - print self.pageContent.toolchainList.count() for i in range(self.pageContent.toolchainList.count()): filename = self.pageContent.toolchainList.item(i).text() - print i, filename self._validationProcess = QProcess() self._validationProcess.start(filename, ["-v"]) - self._validationProcess.waitForStarted(5) - if not self._validationProcess.waitForFinished(5): - self._validationProcess.kill() - print "process killed" + self._validationProcess.waitForStarted(10) + if self._validationProcess.waitForFinished(10): + description = str(self._validationProcess.readAllStandardError()) + infos = bertos_utils.getToolchainInfo(description) + if len(infos.keys()) == 4: + self._validItem(i, infos) + else: + self._invalidItem(i) else: - print self._validationProcess.readAllStandardError() - - def _getToolchainInfo(): - print self._validationProcess.readAllStandardOutput() + self._validationProcess.kill() + self._invalidItem(i) def isComplete(self): if self.pageContent.toolchainList.currentRow() != -1: diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index a946d970..ed66a3b8 100644 --- a/wizard/bertos_utils.py +++ b/wizard/bertos_utils.py @@ -44,13 +44,21 @@ def findToolchains(pathList): def getToolchainInfo(output): info = {} expr = re.compile("Target: .*") - info["target"] = expr.findall(output)[0].split("Target: ")[1] + target = expr.findall(output) + if len(target) == 1: + info["target"] = target[0].split("Target: ")[1] expr = re.compile("gcc version .*") - info["version"] = expr.findall(output)[0].split("gcc version ")[1] + version = expr.findall(output) + if len(version) == 1: + info["version"] = version[0].split("gcc version ")[1] expr = re.compile("Configured with: .*") - info["configured"] = expr.findall(output)[0].split("Configured with: ")[1] + configured = expr.findall(output) + if len(configured) == 1: + info["configured"] = configured[0].split("Configured with: ")[1] expr = re.compile("Thread model: .*") - info["thread"] = expr.findall(output)[0].split("Thread model: ")[1] + thread = expr.findall(output) + if len(thread) == 1: + info["thread"] = thread[0].split("Thread model: ")[1] return info def findDefinitions(ftype, path): -- 2.25.1