From 9195c9b8e87680d702c008edb4de77de54dfa012 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Jun 2013 21:10:57 +0200 Subject: [PATCH] Remove ugly argumentparser bug Before: [21:09] bento:~% cdist Traceback (most recent call last): File "/home/users/nico/p/cdist/cdist/bin/../scripts/cdist", line 232, in commandline() File "/home/users/nico/p/cdist/cdist/bin/../scripts/cdist", line 106, in commandline args.func(args) AttributeError: 'Namespace' object has no attribute 'func' After: [21:11] bento:~% cdist usage: cdist [-h] [-d] [-v] [-V] {banner,config} ... cdist 2.1.1-48-gfd72c60 optional arguments: -h, --help show this help message and exit -d, --debug Set log level to debug -v, --verbose Set log level to info, be more verbose -V, --version Show version Commands: {banner,config} Get cdist at http://www.nico.schottelius.org/software/cdist/ [21:11] bento:~% Signed-off-by: Nico Schottelius --- scripts/cdist | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/cdist b/scripts/cdist index bca4fea7..3c94b38b 100755 --- a/scripts/cdist +++ b/scripts/cdist @@ -103,7 +103,14 @@ def commandline(): logging.root.setLevel(logging.DEBUG) log.debug(args) - args.func(args) + + # Work around python 3.3 bug: + # http://bugs.python.org/issue16308 + # http://bugs.python.org/issue9253 + try: + args.func(args) + except AttributeError: + parser['main'].print_help() def config(args): configinstall(args, mode=cdist.config.Config)