]> code.ossystems Code Review - openembedded-core.git/commitdiff
scripts: ensure not specifying subcommand shows help text
authorPaul Eggleton <paul.eggleton@linux.intel.com>
Mon, 13 Jun 2016 04:43:41 +0000 (16:43 +1200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 14 Jun 2016 11:56:32 +0000 (12:56 +0100)
With Python 2, argparse subparsers behaviour in Python 2 was to print
the usage information if the subparsers argument wasn't specified.
However, with Python 3.2.3 and later a subparsers argument is not
required by default, leading to errors when no arguments are specified:

  AttributeError: 'Namespace' object has no attribute 'func'

Restore the previous desired behaviour of showing the help text for
devtool, recipetool and the devtool-stress script by setting
subparsers.required to True.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/contrib/devtool-stress.py
scripts/devtool
scripts/recipetool

index 2723491b4aece24df44774361bdac153ddf7e547..ab77a2d1f6c913366da62035d7033cce27410fba 100755 (executable)
@@ -213,6 +213,7 @@ def main():
     parser.add_argument('-s', '--skip', help='Skip specified recipes (comma-separated without spaces, wildcards allowed)', metavar='PNLIST')
     parser.add_argument('-c', '--skip-classes', help='Skip recipes inheriting specified classes (comma-separated) - default %(default)s', metavar='CLASSLIST', default='native,nativesdk,cross,cross-canadian,image,populate_sdk,meta,packagegroup')
     subparsers = parser.add_subparsers(title='subcommands', metavar='<subcommand>')
+    subparsers.required = True
 
     parser_modify = subparsers.add_parser('modify',
                                           help='Run "devtool modify" followed by a build with bitbake on matching recipes',
index 63d2ef9053915009d78fc1ef5ab864fd0f4189ac..a93a11f3411311a0959bef28c232ee91e74fca37 100755 (executable)
@@ -301,6 +301,7 @@ def main():
         tinfoil.shutdown()
 
     subparsers = parser.add_subparsers(dest="subparser_name", title='subcommands', metavar='<subcommand>')
+    subparsers.required = True
 
     subparsers.add_subparser_group('sdk', 'SDK maintenance', -2)
     subparsers.add_subparser_group('advanced', 'Advanced', -1)
index 0e8bffb5c05dd7b42ac0871c970d3b4d5d5f1d38..17233d4ef0a34d6a6569a43b485f013126544e0a 100755 (executable)
@@ -60,6 +60,7 @@ def main():
     parser.add_argument('-h', '--help', action='help', default=argparse.SUPPRESS,
                         help='show this help message and exit')
     subparsers = parser.add_subparsers(title='subcommands', metavar='<subcommand>')
+    subparsers.required = True
 
     if global_args.debug:
         logger.setLevel(logging.DEBUG)