Commit 08ac19bb authored by Daniel P. Berrangé's avatar Daniel P. Berrangé

Fix argparser incompatibilities with newer python 3

Python 3 changes such that if no subparser command is listed, it just
throws an error. To get back the old behavior we need to set the
'required'  attribute and a dest name.

Since we treat 'debug' as a global attribute we need to set that on the
top level parser too, otherwise we get a missing attribute error with
newish python 3 too.
Signed-off-by: 's avatarDaniel P. Berrangé <berrange@redhat.com>
parent f5241d11
......@@ -202,7 +202,6 @@ Example supported URI formats:
def gen_purge_args(subparser):
parser = gen_command_parser(subparser, "purge",
_("Purge cached template"))
requires_debug(parser)
requires_template(parser)
requires_template_dir(parser)
parser.set_defaults(func=purge)
......@@ -210,7 +209,6 @@ def gen_purge_args(subparser):
def gen_prepare_args(subparser):
parser = gen_command_parser(subparser, "prepare",
_("Prepare local template"))
requires_debug(parser)
requires_template(parser)
requires_connect(parser)
requires_template_dir(parser)
......@@ -219,7 +217,6 @@ def gen_prepare_args(subparser):
def gen_run_args(subparser):
parser = gen_command_parser(subparser, "run",
_("Run an instance of a template"))
requires_debug(parser)
requires_name(parser)
requires_template(parser)
requires_connect(parser)
......@@ -238,7 +235,6 @@ def gen_run_args(subparser):
def gen_list_args(subparser):
parser = gen_command_parser(subparser, "list",
_("List locally cached images"))
requires_debug(parser)
requires_template_dir(parser)
parser.add_argument("-s","--source",
......@@ -249,7 +245,11 @@ def gen_list_args(subparser):
def main():
parser = argparse.ArgumentParser(description="Sandbox Container Image Tool")
requires_debug(parser)
subparser = parser.add_subparsers(help=_("commands"))
subparser.required = True
subparser.dest = "command"
gen_purge_args(subparser)
gen_prepare_args(subparser)
gen_run_args(subparser)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment