From: W. Trevor King Date: Tue, 11 Dec 2012 16:49:53 +0000 (-0500) Subject: pg.py: handle command-less invocation cleanly X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e96504f5e6f345137ceba5070ad7619ee13ab0e3;p=pygrader.git 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' --- 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)