toos: fix handling default command (qvm-device, qvm-volume, ...)
When command isn't specified, command variable is set to None. Lets handle this situation gracefuly.
This commit is contained in:
parent
065eb036df
commit
a184e35a03
@ -389,6 +389,8 @@ class QubesArgumentParser(argparse.ArgumentParser):
|
||||
argparse._SubParsersAction): # pylint: disable=no-member
|
||||
assert hasattr(namespace, 'command')
|
||||
command = namespace.command
|
||||
if command is None:
|
||||
continue
|
||||
subparser = action._name_parser_map[command]
|
||||
for subaction in subparser._actions:
|
||||
if issubclass(subaction.__class__, QubesAction):
|
||||
|
@ -201,6 +201,10 @@ def get_parser(device_class=None):
|
||||
else:
|
||||
parser.add_argument('devclass', metavar='DEVICE_CLASS', action='store',
|
||||
help="Device class to manage ('pci', 'usb', etc)")
|
||||
|
||||
# default action
|
||||
parser.set_defaults(func=list_devices)
|
||||
|
||||
sub_parsers = parser.add_subparsers(
|
||||
title='commands',
|
||||
description="For more information see qvm-device command -h",
|
||||
|
@ -192,6 +192,7 @@ def init_extend_parser(sub_parsers):
|
||||
extend_parser.add_argument('size', help='New size in bytes')
|
||||
extend_parser.set_defaults(func=extend_volumes)
|
||||
|
||||
|
||||
def get_parser():
|
||||
'''Create :py:class:`argparse.ArgumentParser` suitable for
|
||||
:program:`qvm-block`.
|
||||
@ -207,6 +208,8 @@ def get_parser():
|
||||
init_extend_parser(sub_parsers)
|
||||
init_list_parser(sub_parsers)
|
||||
init_revert_parser(sub_parsers)
|
||||
# default action
|
||||
parser.set_defaults(func=list_volumes)
|
||||
|
||||
return parser
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user