gnuradio / pybombs

PyBOMBS (Python Build Overlay Managed Bundle System) is the GNU Radio install management system for resolving dependencies and pulling in out-of-tree projects.
https://gnuradio.org
GNU General Public License v3.0
416 stars 189 forks source link

Crash when executing pybombs without arguments on Python 3 #544

Closed argilo closed 5 years ago

argilo commented 5 years ago

After running pip3 install pybombs on an Ubuntu 18.04 machine, pybombs fails as follows when run without command line arguments:

$ pybombs

PyBOMBS.ConfigManager - INFO - Prefix Python version is: 3.6.8
PyBOMBS - INFO - PyBOMBS Version 2.3.3
Traceback (most recent call last):
  File "/home/argilo/.local/bin/pybombs", line 11, in <module>
    sys.exit(main())
  File "/home/argilo/.local/lib/python3.6/site-packages/pybombs/main.py", line 32, in main
    return dispatch() or 0
  File "/home/argilo/.local/lib/python3.6/site-packages/pybombs/commands/base.py", line 194, in dispatch
    return get_cmd_dict(cmd_list)[args.command](cmd=args.command, args=args).run()
KeyError: None

I suspect the problem might be the one described here: https://stackoverflow.com/questions/22990977/why-does-this-argparse-code-behave-differently-between-python-2-and-3

The following code change appears to fix the problem:

--- a/pybombs/commands/base.py
+++ b/pybombs/commands/base.py
@@ -143,6 +143,7 @@ def init_arg_parser(show_help_for=None, hide_hidden=True):
         dest='command',
         metavar='<command>',
     )
+    subparsers.required = True
     if hide_hidden:
         parser.error = dummy_error
     # Set up options for each command:

After this change, I get the following result:

$ pybombs
PyBOMBS.ConfigManager - INFO - Prefix Python version is: 3.6.8
PyBOMBS - INFO - PyBOMBS Version 2.3.3
usage: pybombs [-h] [--version] [-p PREFIX] [--prefix-conf PREFIX_CONF]
               [--config CONFIG] [--config-file CONFIG_FILE] [-r RECIPES] [-q]
               [-v] [-y]
               <command> ...
pybombs: error: the following arguments are required: <command>
mbr0wn commented 5 years ago

I merged that diff.