diff options
author | Guido Günther <agx@sigxcpu.org> | 2014-01-05 15:15:57 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2014-01-05 15:27:55 +0100 |
commit | 7c64575a685edaa4962c811d9d9321a615e7d22a (patch) | |
tree | 3c0f73ebf9df74549f2d9dbabb0c4f39edc4144d | |
parent | 78f36734be1b2ff1979ca14bd18cbd065093175b (diff) | |
download | git-buildpackage-7c64575a685edaa4962c811d9d9321a615e7d22a.tar.gz git-buildpackage-7c64575a685edaa4962c811d9d9321a615e7d22a.tar.bz2 git-buildpackage-7c64575a685edaa4962c811d9d9321a615e7d22a.zip |
Avoid backtrace on config file parse errors
"gbp buildpackage" did this already but others didn't
Closes: #733759
-rwxr-xr-x | gbp/scripts/clone.py | 12 | ||||
-rw-r--r-- | gbp/scripts/import_dsc.py | 2 | ||||
-rw-r--r-- | gbp/scripts/import_orig.py | 3 | ||||
-rwxr-xr-x | gbp/scripts/pq.py | 23 | ||||
-rwxr-xr-x | gbp/scripts/pull.py | 25 |
5 files changed, 50 insertions, 15 deletions
diff --git a/gbp/scripts/clone.py b/gbp/scripts/clone.py index 15e11741..251cef21 100755 --- a/gbp/scripts/clone.py +++ b/gbp/scripts/clone.py @@ -19,6 +19,7 @@ # """clone a repo and set it up for gbp""" +import ConfigParser import sys import os, os.path from gbp.config import (GbpOptionParser, GbpOptionGroup) @@ -29,8 +30,13 @@ import gbp.log def parse_args (argv): - parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='', - usage='%prog [options] repository - clone a remote repository') + try: + parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='', + usage='%prog [options] repository - clone a remote repository') + except ConfigParser.ParsingError as err: + gbp.log.err(err) + return None, None + branch_group = GbpOptionGroup(parser, "branch options", "branch tracking and layout options") parser.add_option_group(branch_group) @@ -58,6 +64,8 @@ def main(argv): retval = 0 (options, args) = parse_args(argv) + if not options: + return 1 if len(args) < 2: gbp.log.err("Need a repository to clone.") diff --git a/gbp/scripts/import_dsc.py b/gbp/scripts/import_dsc.py index 2da4aacb..d60e0d16 100644 --- a/gbp/scripts/import_dsc.py +++ b/gbp/scripts/import_dsc.py @@ -278,6 +278,8 @@ def main(argv): parents = None options, args = parse_args(argv) + if not options: + return 1 try: if len(args) != 1: diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py index bd2ce1a0..dbb1ce9d 100644 --- a/gbp/scripts/import_orig.py +++ b/gbp/scripts/import_orig.py @@ -244,6 +244,9 @@ def main(argv): linked = False (options, args) = parse_args(argv) + if not options: + return 1 + try: source = find_source(options, args) if not source: diff --git a/gbp/scripts/pq.py b/gbp/scripts/pq.py index 8682d855..41d3ddf8 100755 --- a/gbp/scripts/pq.py +++ b/gbp/scripts/pq.py @@ -17,6 +17,7 @@ # """manage patches in a patch queue""" +import ConfigParser import errno import os import shutil @@ -209,10 +210,9 @@ def switch_pq(repo, current): switch_to_pq_branch(repo, current) -def main(argv): - retval = 0 - - parser = GbpOptionParserDebian(command=os.path.basename(argv[0]), prefix='', +def parse_args(argv): + try: + parser = GbpOptionParserDebian(command=os.path.basename(argv[0]), prefix='', usage="%prog [options] action - maintain patches on a patch queue branch\n" "Actions:\n" " export export the patch queue associated to the current branch\n" @@ -224,6 +224,10 @@ def main(argv): " drop drop (delete) the patch queue associated to the current branch.\n" " apply apply a patch\n" " switch switch to patch-queue branch and vice versa") + except ConfigParser.ParsingError as err: + gbp.log.err(err) + return None, None + parser.add_boolean_config_file_option(option_name="patch-numbers", dest="patch_numbers") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbose command execution") @@ -234,8 +238,16 @@ def main(argv): parser.add_config_file_option(option_name="color", dest="color", type='tristate') parser.add_config_file_option(option_name="color-scheme", dest="color_scheme") + return parser.parse_args(argv) + + +def main(argv): + retval = 0 + + (options, args) = parse_args(argv) + if not options: + return 1 - (options, args) = parser.parse_args(argv) gbp.log.setup(options.color, options.verbose, options.color_scheme) if len(args) < 2: @@ -294,4 +306,3 @@ def main(argv): if __name__ == '__main__': sys.exit(main(sys.argv)) - diff --git a/gbp/scripts/pull.py b/gbp/scripts/pull.py index d0a74422..03be9fc7 100755 --- a/gbp/scripts/pull.py +++ b/gbp/scripts/pull.py @@ -1,6 +1,6 @@ # vim: set fileencoding=utf-8 : # -# (C) 2009 Guido Guenther <agx@sigxcpu.org> +# (C) 2009,2013 Guido Guenther <agx@sigxcpu.org> # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or @@ -19,6 +19,7 @@ # """fast forward debian, upstream and pristine-tar branch""" +import ConfigParser import sys import os, os.path from gbp.command_wrappers import (Command, CommandExecFailed) @@ -67,12 +68,14 @@ def fast_forward_branch(branch, repo, options): msg="gbp: forward %s to %s" % (branch, remote)) return update -def main(argv): - retval = 0 - current = None - - parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='', +def parse_args(argv): + try: + parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='', usage='%prog [options] - safely update a repository from remote') + except ConfigParser.ParsingError as err: + gbp.log.err(err) + return None, None + branch_group = GbpOptionGroup(parser, "branch options", "branch update and layout options") parser.add_option_group(branch_group) branch_group.add_boolean_config_file_option(option_name = "ignore-branch", dest="ignore_branch") @@ -90,9 +93,17 @@ def main(argv): parser.add_config_file_option(option_name="color", dest="color", type='tristate') parser.add_config_file_option(option_name="color-scheme", dest="color_scheme") + return parser.parse_args(argv) - (options, args) = parser.parse_args(argv) +def main(argv): + retval = 0 + current = None + + (options, args) = parse_args(argv) + if not options: + return 1 + gbp.log.setup(options.color, options.verbose, options.color_scheme) try: |