dialog = BToolchainDialog()
if dialog.exec_():
toolchain = qvariant_converter.getStringDict(dialog.toolchain_page.currentItem().data(Qt.UserRole))
- toolchain_page.setProjectInfo("TOOLCHAIN", toolchain)
+ dialog.toolchain_page.setProjectInfo("TOOLCHAIN", toolchain)
def changeBertosVersion(self):
dialog = BVersionDialog()
# TODO: to be moved in BToolchainPage
for toolchain_row in range(toolchain_page.pageContent.toolchainList.count()):
toolchain = qvariant_converter.getStringDict(toolchain_page.pageContent.toolchainList.item(toolchain_row).data(Qt.UserRole))
- if toolchain["path"] == current_toolchain["path"]:
+ if current_toolchain and toolchain["path"] == current_toolchain["path"]:
toolchain_page.pageContent.toolchainList.setCurrentRow(toolchain_row)
toolchain_page.selectionChanged()
break
+ self.toolchain_page = toolchain_page
layout.addWidget(toolchain_page)
button_layout = QHBoxLayout()
button_layout.addStretch()
layout = QVBoxLayout()
version_page = BVersionPage()
version_page.reloadData()
+ self.version_page = version_page
layout.addWidget(version_page)
button_layout = QHBoxLayout()
button_layout.addStretch()
toolchains[toolchain] = True
sel_toolchain = self.projectInfo("TOOLCHAIN")
for key, value in toolchains.items():
- item = QListWidgetItem(key)
- item.setData(Qt.UserRole, qvariant_converter.convertStringDict({"path": key}))
- self.pageContent.toolchainList.addItem(item)
- if sel_toolchain and sel_toolchain["path"] == key:
- self.pageContent.toolchainList.setCurrentItem(item)
- if value:
- self.validateToolchain(self.pageContent.toolchainList.row(item))
+ if os.path.exists(key):
+ item = QListWidgetItem(key)
+ item.setData(Qt.UserRole, qvariant_converter.convertStringDict({"path": key}))
+ self.pageContent.toolchainList.addItem(item)
+ if sel_toolchain and sel_toolchain["path"] == key:
+ self.pageContent.toolchainList.setCurrentItem(item)
+ if value:
+ self.validateToolchain(self.pageContent.toolchainList.row(item))
+
+ def currentToolchain(self):
+ selected_toolchain = qvariant_converter.getStringDict(self.pageContent.toolchainList.currentItem().data(Qt.UserRole))
+ return selected_toolchain
def _clearList(self):
"""
--- /dev/null
+#!/usr/bin/env python\r
+# encoding: utf-8\r
+#\r
+# This file is part of BeRTOS.\r
+#\r
+# Bertos is free software; you can redistribute it and/or modify\r
+# it under the terms of the GNU General Public License as published by\r
+# the Free Software Foundation; either version 2 of the License, or\r
+# (at your option) any later version.\r
+#\r
+# This program is distributed in the hope that it will be useful,\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+# GNU General Public License for more details.\r
+#\r
+# You should have received a copy of the GNU General Public License\r
+# along with this program; if not, write to the Free Software\r
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\r
+#\r
+# As a special exception, you may use this file as part of a free software\r
+# library without restriction. Specifically, if other files instantiate\r
+# templates or use macros or inline functions from this file, or you compile\r
+# this file and link it with other files to produce an executable, this\r
+# file does not by itself cause the resulting executable to be covered by\r
+# the GNU General Public License. This exception does not however\r
+# invalidate any other reasons why the executable file might be covered by\r
+# the GNU General Public License.\r
+#\r
+# Copyright 2008 Develer S.r.l. (http://www.develer.com/)\r
+#\r
+# $Id: DefineException.py 2645 2009-04-23 09:28:13Z duplo $\r
+#\r
+# Author: Lorenzo Berni <duplo@develer.com>\r
+#\r
+\r
+class ToolchainException(Exception):\r
+ def __init__(self, partial_project):\r
+ self.partial_project = partial_project\r
+\r
+class VersionException(Exception):\r
+ def __init__(self, partial_project):\r
+ self.partial_project = partial_project\r
from BCreationPage import BCreationPage
from BFinalPage import BFinalPage
-from BEditingDialog import BEditingDialog
+from BEditingDialog import BEditingDialog, BVersionDialog, BToolchainDialog
import bertos_utils
+from LoadException import VersionException, ToolchainException
+
def newProject():
page_list = [BFolderPage, BVersionPage, BCpuPage, BToolchainPage, BModulePage, BOutputPage, BCreationPage, BFinalPage]
wizard = BWizard.BWizard(page_list)
sys.exit()
def editProject(project_file):
- QApplication.instance().project = bertos_utils.loadBertosProject(project_file)
+ info_dict = {}
+ while(True):
+ try:
+ QApplication.instance().project = bertos_utils.loadBertosProject(project_file, info_dict)
+ except VersionException:
+ QMessageBox.critical(
+ None,
+ QObject().tr("BeRTOS version not found!"),
+ QObject().tr("The selected BeRTOS version is not found, please select an existing one...")
+ )
+ dialog = BVersionDialog()
+ if dialog.exec_():
+ version = dialog.version_page.currentVersion()
+ info_dict["SOURCES_PATH"] = version
+ continue
+ except ToolchainException, exc:
+ QMessageBox.critical(
+ None,
+ QObject().tr("Toolchain not found!"),
+ QObject().tr("The selected toolchain is not found, please select an existing one...")
+ )
+ QApplication.instance().project = exc.partial_project
+ dialog = BToolchainDialog()
+ if dialog.exec_():
+ toolchain = dialog.toolchain_page.currentToolchain()
+ info_dict["TOOLCHAIN"] = toolchain
+ continue
+ break
dialog = BEditingDialog()
dialog.exec_()
import DefineException
import BProject
+from LoadException import VersionException, ToolchainException
+
def isBertosDir(directory):
return os.path.exists(directory + "/VERSION")
def bertosVersion(directory):
return open(directory + "/VERSION").readline().strip()
-def loadBertosProject(project_file):
+def loadBertosProject(project_file, info_dict):
project_data = pickle.loads(open(project_file, "r").read())
project_info = BProject.BProject()
project_info.setInfo("PROJECT_PATH", os.path.dirname(project_file))
- project_info.setInfo("SOURCES_PATH", project_data["SOURCES_PATH"])
- project_info.setInfo("TOOLCHAIN", project_data["TOOLCHAIN"])
- project_info.setInfo("SELECTED_FREQ", project_data["SELECTED_FREQ"])
- project_info.setInfo("OUTPUT", project_data["OUTPUT"])
+ if "SOURCES_PATH" in info_dict:
+ project_data["SOURCES_PATH"] = info_dict["SOURCES_PATH"]
+ if os.path.exists(project_data["SOURCES_PATH"]):
+ project_info.setInfo("SOURCES_PATH", project_data["SOURCES_PATH"])
+ else:
+ raise VersionException(project_info)
loadSourceTree(project_info)
cpu_name = project_data["CPU_NAME"]
project_info.setInfo("CPU_NAME", cpu_name)
else:
tag_dict[tag] = False
project_info.setInfo("ALL_CPU_TAGS", tag_dict)
+ if "TOOLCHAIN" in info_dict:
+ project_data["TOOLCHAIN"] = info_dict["TOOLCHAIN"]
+ if os.path.exists(project_data["TOOLCHAIN"]["path"]):
+ project_info.setInfo("TOOLCHAIN", project_data["TOOLCHAIN"])
+ else:
+ raise ToolchainException(project_info)
+ project_info.setInfo("SELECTED_FREQ", project_data["SELECTED_FREQ"])
+ project_info.setInfo("OUTPUT", project_data["OUTPUT"])
loadModuleData(project_info, True)
setEnabledModules(project_info, project_data["ENABLED_MODULES"])
return project_info