From e96504f5e6f345137ceba5070ad7619ee13ab0e3 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 11 Dec 2012 11:49:53 -0500 Subject: [PATCH] pg.py: handle command-less invocation cleanly This avoids: Traceback (most recent call last): File "/.../pg.py", line 202, in func_args = _inspect.getargspec(args.func).args AttributeError: 'Namespace' object has no attribute 'func' --- bin/pg.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bin/pg.py b/bin/pg.py index b8db60e..23f4d63 100755 --- a/bin/pg.py +++ b/bin/pg.py @@ -178,6 +178,11 @@ if __name__ == '__main__': args = parser.parse_args() + if not hasattr(args, 'func'): + # no command selected; print help and die + parser.print_help() + _sys.exit(0) + if args.verbose: _LOG.setLevel(max(_logging.DEBUG, _LOG.level - 10*args.verbose)) _pgp_mime.LOG.setLevel(_LOG.level) -- 2.26.2