From: Zhang Qiang Date: Wed, 27 Jun 2012 08:27:50 +0000 (+0800) Subject: More error handling with gbs conf X-Git-Tag: 0.7.1~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f96084ace21762a900f2dda5e03b5ec68db25277;p=tools%2Fgbs.git More error handling with gbs conf --- diff --git a/gitbuildsys/cmd_build.py b/gitbuildsys/cmd_build.py index ecb71a9..f1b4f2b 100644 --- a/gitbuildsys/cmd_build.py +++ b/gitbuildsys/cmd_build.py @@ -180,10 +180,10 @@ def get_reops_conf(): try: (name, key) = opt.split('.') except ValueError: - raise Exception("Invalid repo option: %s" % opt) + raise errors.ConfigError("invalid repo option: %s" % opt) else: if key not in ('url', 'user', 'passwdx'): - raise Exception("Invalid repo option: %s" % opt) + raise errors.ConfigError("invalid repo option: %s" % opt) repos.add(name) # get repo settings form build section diff --git a/gitbuildsys/conf.py b/gitbuildsys/conf.py index 8dc99a3..41b5107 100644 --- a/gitbuildsys/conf.py +++ b/gitbuildsys/conf.py @@ -147,7 +147,7 @@ class BrainConfigParser(SafeConfigParser): # if any parsing errors occurred, raise an exception if exc: - raise exc + raise errors.ConfigError(str(exc)) def set(self, section, option, value, replace_opt=None): """When set new value, need to update the readin file lines, @@ -171,7 +171,10 @@ class BrainConfigParser(SafeConfigParser): # if reach here, sec is the last one return -1 - SafeConfigParser.set(self, section, option, value) + try: + SafeConfigParser.set(self, section, option, value) + except NoSectionError, err: + raise errors.ConfigError(str(err)) # If the code reach here, it means the section and key are ok if replace_opt is None: diff --git a/tools/gbs b/tools/gbs index d99c2b7..c6c1d41 100755 --- a/tools/gbs +++ b/tools/gbs @@ -21,7 +21,6 @@ import re from gitbuildsys.__version__ import VERSION from gitbuildsys import msger, cmdln, errors -from gitbuildsys.conf import configmgr def handle_repository(option, opt_str, value, parser): if not value: @@ -326,6 +325,7 @@ class Gbs(cmdln.Cmdln): if __name__ == '__main__': try: + from gitbuildsys.conf import configmgr sys.exit(Gbs().main()) except KeyboardInterrupt: