X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=wizard%2FBToolchainPage.py;h=18935ec5f598db267642404576bacd0156429119;hb=fdb18feb2dc80cfd619b2eb6b1c5ad194106de05;hp=6b39ade822cdc4539a7c15ce4c2a5e1526ade410;hpb=8db6f7d55f24f972b48a0797f0a3b289b465b943;p=bertos.git diff --git a/wizard/BToolchainPage.py b/wizard/BToolchainPage.py index 6b39ade8..18935ec5 100644 --- a/wizard/BToolchainPage.py +++ b/wizard/BToolchainPage.py @@ -10,39 +10,33 @@ # import os +import collections from BWizardPage import * import BToolchainSearch import bertos_utils -if PYQT_VERSION_STR > "4.4.3": - import qvariant_converter_new as qvariant_converter -else: - import qvariant_converter_old as qvariant_converter +import qvariant_converter + +from const import * class BToolchainPage(BWizardPage): def __init__(self): - BWizardPage.__init__(self, "toolchain_select.ui") + BWizardPage.__init__(self, UI_LOCATION + "/toolchain_select.ui") self.setTitle(self.tr("Select toolchain")) - self._validationProcess = None + self._validation_process = None + self._updateUi() #self._populateToolchainList() self._connectSignals() def _updateUi(self): - if self.pageContent.customDirBox.isChecked(): - self._enableCustomDir() - else: - self._disableCustomDir() - if self.pageContent.pathBox.isChecked() or (self.pageContent.customDirBox.isChecked() and self.pageContent.customDirList.count() != 0): - self.pageContent.doSearchButton.setEnabled(True) - else: - self.pageContent.doSearchButton.setEnabled(False) + self.pageContent.infoLabel.setVisible(False) def _populateToolchainList(self): toolchains = self.toolchains() for key, value in toolchains.items(): item = QListWidgetItem(key) - item.setData(Qt.UserRole, qvariant_converter.convertString(key)) + item.setData(Qt.UserRole, qvariant_converter.convertStringDict({"path": key})) self.pageContent.toolchainList.addItem(item) if value: self.validateToolchain(self.pageContent.toolchainList.row(item)) @@ -51,21 +45,26 @@ class BToolchainPage(BWizardPage): self.pageContent.toolchainList.clear() def _selectionChanged(self): - self.emit(SIGNAL("completeChanged()")) + if self.pageContent.toolchainList.currentRow() != -1: + infos = collections.defaultdict(lambda: unicode("not defined")) + infos.update(qvariant_converter.getStringDict(self.pageContent.toolchainList.currentItem().data(Qt.UserRole))) + self.pageContent.infoLabel.setText("GCC " + infos["version"] + " (" + infos["build"] + ")\nTarget: " + infos["target"] + "\nPath: " + os.path.normpath(infos["path"])) + self.pageContent.infoLabel.setVisible(True) + self.emit(SIGNAL("completeChanged()")) def _search(self): - dirList = self.searchDirList() - if(self.pathSearch()): - dirList += [element for element in bertos_utils.getSystemPath()] - toolchainList = bertos_utils.findToolchains(dirList) - storedToolchains = self.toolchains() - for element in toolchainList: - if not element in storedToolchains.keys(): + dir_list = self.searchDirList() + if self.pathSearch(): + dir_list += [element for element in bertos_utils.getSystemPath()] + toolchain_list = bertos_utils.findToolchains(dir_list) + stored_toolchains = self.toolchains() + for element in toolchain_list: + if not element in stored_toolchains.keys(): item = QListWidgetItem(element) - item.setData(Qt.UserRole, qvariant_converter.convertString(element)) + item.setData(Qt.UserRole, qvariant_converter.convertStringDict({"path": element})) self.pageContent.toolchainList.addItem(item) - storedToolchains[element] = False - self.setToolchains(storedToolchains) + stored_toolchains[element] = False + self.setToolchains(stored_toolchains) def _connectSignals(self): self.connect(self.pageContent.toolchainList, SIGNAL("itemSelectionChanged()"), self._selectionChanged) @@ -76,12 +75,16 @@ class BToolchainPage(BWizardPage): def _validItem(self, index, infos): item = self.pageContent.toolchainList.item(index) + new_data = qvariant_converter.getStringDict(self.pageContent.toolchainList.item(index).data(Qt.UserRole)) + new_data.update(infos) + item.setData(Qt.UserRole, qvariant_converter.convertStringDict(new_data)) needed = self._projectInfoRetrieve("CPU_INFOS") - if infos["target"].find(qvariant_converter.getString(needed["TOOLCHAIN"])) != -1: + if "target" in infos.keys() and infos["target"].find(needed["TOOLCHAIN"]) != -1: item.setIcon(QIcon(":/images/ok.png")) else: item.setIcon(QIcon(":/images/warning.png")) - item.setText("GCC " + infos["version"] + " - " + infos["target"]) + if "version" in infos.keys() and "target" in infos.keys(): + item.setText("GCC " + infos["version"] + " - " + infos["target"]) def _invalidItem(self, index): item = self.pageContent.toolchainList.item(index) @@ -91,7 +94,7 @@ class BToolchainPage(BWizardPage): sel_toolchain = QFileDialog.getOpenFileName(self, self.tr("Choose the toolchain"), "") if not sel_toolchain.isEmpty(): item = QListWidgetItem(sel_toolchain) - item.setData(Qt.UserRole, qvariant_converter.convertString(sel_toolchain)) + item.setData(Qt.UserRole, qvariant_converter.convertString({"path": sel_toolchain})) self.pageContent.toolchainList.addItem(item) toolchains = self.toolchains() toolchains[sel_toolchain] = False @@ -100,7 +103,7 @@ class BToolchainPage(BWizardPage): def removeToolchain(self): if self.pageContent.toolchainList.currentRow() != -1: item = self.pageContent.toolchainList.takeItem(self.pageContent.toolchainList.currentRow()) - toolchain = qvariant_converter.getString(item.data(Qt.UserRole)) + toolchain = qvariant_converter.getStringDict(item.data(Qt.UserRole))["path"] toolchains = self.toolchains() del toolchains[toolchain] self.setToolchains(toolchains) @@ -111,23 +114,38 @@ class BToolchainPage(BWizardPage): search.exec_() def validateAllToolchains(self): + QApplication.instance().setOverrideCursor(Qt.WaitCursor) for i in range(self.pageContent.toolchainList.count()): self.validateToolchain(i) + QApplication.instance().restoreOverrideCursor() def validateToolchain(self, i): - filename = qvariant_converter.getString(self.pageContent.toolchainList.item(i).data(Qt.UserRole)) - self._validationProcess = QProcess() - self._validationProcess.start(filename, ["-v"]) - self._validationProcess.waitForStarted(1000) - if self._validationProcess.waitForFinished(200): - description = str(self._validationProcess.readAllStandardError()) - infos = bertos_utils.getToolchainInfo(description) - if len(infos.keys()) >= 4: - self._validItem(i, infos) + filename = qvariant_converter.getStringDict(self.pageContent.toolchainList.item(i).data(Qt.UserRole))["path"] + valid = False + info = {} + ## Check for the other tools of the toolchain + for tool in TOOLCHAIN_ITEMS: + if os.path.exists(filename.replace("gcc", tool)): + valid = True + else: + valid = False + break + ## Try to retrieve the informations about the toolchain only for the valid toolchains + if valid: + self._validation_process = QProcess() + self._validation_process.start(filename, ["-v"]) + self._validation_process.waitForStarted(1000) + if self._validation_process.waitForFinished(200): + description = str(self._validation_process.readAllStandardError()) + info = bertos_utils.getToolchainInfo(description) + if len(info.keys()) >= 4: + valid = True else: - self._invalidItem(i) + self._validation_process.kill() + ## Add the item in the list with the appropriate associate data. + if valid: + self._validItem(i, info) else: - self._validationProcess.kill() self._invalidItem(i) toolchains = self.toolchains() toolchains[filename] = True @@ -136,11 +154,12 @@ class BToolchainPage(BWizardPage): def isComplete(self): if self.pageContent.toolchainList.currentRow() != -1: self._projectInfoStore("TOOLCHAIN", - qvariant_converter.getString(self.pageContent.toolchainList.item(self.pageContent.toolchainList.currentRow()).data(Qt.UserRole))) + qvariant_converter.getStringDict(self.pageContent.toolchainList.currentItem().data(Qt.UserRole))) return True else: return False def reloadData(self): self._clearList() + self._updateUi() self._populateToolchainList() \ No newline at end of file