From f545010462b9a313fe3bf160bca9e44c3ea77b55 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Mon, 4 Jul 2016 20:03:26 +0200 Subject: Give more instructions when config is unparseable and make return codes and messages consistent. This allows us to move some test code from the component tests to the unit tests which is always nice. Closes: #733640 --- gbp/scripts/create_remote_repo.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'gbp/scripts/create_remote_repo.py') diff --git a/gbp/scripts/create_remote_repo.py b/gbp/scripts/create_remote_repo.py index db60959d..ffc32eaa 100644 --- a/gbp/scripts/create_remote_repo.py +++ b/gbp/scripts/create_remote_repo.py @@ -20,7 +20,6 @@ from __future__ import print_function -from six.moves import configparser import sys import os, os.path from six.moves import urllib @@ -36,8 +35,11 @@ from gbp.config import (GbpOptionParserDebian, GbpOptionGroup) from gbp.errors import GbpError from gbp.git import GitRepositoryError from gbp.deb.git import DebianGitRepository +from gbp.scripts.common import ExitCodes + import gbp.log + def print_config(remote, branches): """ Print out the git config to push to the newly created repo. @@ -237,7 +239,7 @@ def build_parser(name, sections=[]): usage='%prog [options] - ' 'create a remote repository', sections=sections) - except configparser.ParsingError as err: + except GbpError as err: gbp.log.err(err) return None @@ -308,11 +310,10 @@ def main(argv): changelog = 'debian/changelog' cmd = [] - try: - options, args = parse_args(argv) - except Exception as e: - print("%s" % e, file=sys.stderr) - return 1 + options, args = parse_args(argv) + + if not options: + return ExitCodes.parse_error gbp.log.setup(options.color, options.verbose, options.color_scheme) try: -- cgit v1.2.3