From cf2757f24fce4a6d04ddd023d06ee6bb2a20b7fa Mon Sep 17 00:00:00 2001 From: duplo Date: Mon, 21 Jun 2010 13:18:35 +0000 Subject: [PATCH] Add exception handling for parsing error within the preset route. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3927 38d2e660-2303-0410-9eaa-f027e97ec537 --- wizard/BProject.py | 4 ++-- wizard/BProjectPresets.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/wizard/BProject.py b/wizard/BProject.py index 366e9a75..1e477c68 100644 --- a/wizard/BProject.py +++ b/wizard/BProject.py @@ -245,7 +245,7 @@ class BProject(object): try: to_be_parsed, module_dict = loadModuleDefinition(comment_list[0]) except ParseError, err: - raise DefineException.ModuleDefineException(path, err.line_number, err.line) + raise DefineException.ModuleDefineException(os.path.join(path, filename), err.line_number, err.line) for module, information in module_dict.items(): if "depends" not in information: information["depends"] = () @@ -283,7 +283,7 @@ class BProject(object): list_dict = loadDefineLists(comment_list[1:]) list_info_dict.update(list_dict) except ParseError, err: - raise DefineException.EnumDefineException(path, err.line_number, err.line) + raise DefineException.EnumDefineException(os.path.join(path, filename), err.line_number, err.line) for tag in self.infos["CPU_INFOS"]["CPU_TAGS"]: for filename, path in self.findDefinitions("*_" + tag + ".h"): comment_list = getCommentList(open(path + "/" + filename, "r").read()) diff --git a/wizard/BProjectPresets.py b/wizard/BProjectPresets.py index 9afed4f4..2b5dd673 100644 --- a/wizard/BProjectPresets.py +++ b/wizard/BProjectPresets.py @@ -45,6 +45,8 @@ from BWizardPage import BWizardPage from BCreationPage import BCreationPage from BToolchainPage import BToolchainPage +from DefineException import ModuleDefineException + from bertos_utils import _cmp from toolchain_manager import ToolchainManager @@ -121,7 +123,10 @@ class BProjectPresets(BWizardPage): preset_path = self.selected_path try: QApplication.instance().setOverrideCursor(Qt.WaitCursor) - self.project.loadProjectFromPreset(preset_path) + try: + self.project.loadProjectFromPreset(preset_path) + except ModuleDefineException, e: + self.exceptionOccurred(self.tr("Error parsing line '%2' in file %1").arg(e.path).arg(e.line)) self.setProjectInfo("PRESET_LOADED", True) finally: QApplication.instance().restoreOverrideCursor() -- 2.25.1