(subparsers)
return p
Subparser for usb command
Subparser for usb command
Subparser for usb command
def subparser(subparsers):
    """Subparser for usb command"""
    p = subparsers.add_parser('usb',
                              description="USB DVB-S2 receiver manager",
                              help='Manage Linux USB DVB-S2 receiver',
                              formatter_class=ArgumentDefaultsHelpFormatter)

    # Common parameters
    p.add_argument('-a',
                   '--adapter',
                   default=None,
                   help='DVB-S2 adapter number or model')

    p.add_argument('-f',
                   '--frontend',
                   default=None,
                   help='DVB-S2 adapter\'s frontend number')

    p.set_defaults(func=print_help)

    subsubparsers = p.add_subparsers(title='subcommands',
                                     help='Target sub-command')

    # Launch
    p1 = subsubparsers.add_parser(
        'launch',
        description="Launch a USB DVB-S2 receiver",
        help='Launch a Linux USB DVB-S2 receiver',
        formatter_class=ArgumentDefaultsHelpFormatter)

    p1.add_argument(
        '-l',
        '--lnb',
        choices=defs.lnb_options,
        default=None,
        metavar='',
        help="LNB being used. If not specified, it will be defined "
        "automatically. Choose from the following LNBs supported "
        "by v4l-utils: " + ", ".join(defs.lnb_options))

    p1.add_argument('-r',
                    '--record-file',
                    default=None,
                    help='Record MPEG-TS traffic into a target file')

    p1.add_argument('-t',
                    '--timeout',
                    default=None,
                    help='Stop zapping after a timeout in seconds - useful to \
                    control recording time')

    p1.add_argument('-m',
                    '--monitor',
                    default=False,
                    action='store_true',
                    help='Launch dvbv5-zap in monitor mode to debug MPEG TS '
                    'packet and bit rates')

    monitoring.add_to_parser(p1)

    p1.set_defaults(func=launch)

    # Initial configurations
    p2 = subsubparsers.add_parser(
        'config',
        aliases=['cfg'],
        description='Initial configurations',
        help='Configure DVB-S2 interface(s) and\
                                  the host',
        formatter_class=ArgumentDefaultsHelpFormatter)
    p2.add_argument('-U',
                    '--ule',
                    default=False,
                    action='store_true',
                    help='Use ULE encapsulation instead of MPE')

    p2.add_argument('--skip-rp',
                    default=False,
                    action='store_true',
                    help='Skip settting of reverse path filters')

    p2.add_argument('--skip-firewall',
                    default=False,
                    action='store_true',
                    help='Skip configuration of firewall rules')

    p2.add_argument('--pid',
                    default=defs.pids,
                    type=int,
                    nargs='+',
                    help='List of PIDs to be listened to by dvbnet')

    p2.add_argument('-i',
                    '--ip',
                    default=None,
                    nargs='+',
                    help='IP address set for each DVB-S2 net \
                    interface with subnet mask in CIDR notation')

    p2.add_argument('-y',
                    '--yes',
                    default=False,
                    action='store_true',
                    help="Default to answering Yes to configuration prompts")

    p2.add_argument("--dry-run",
                    action='store_true',
                    default=False,
                    help="Print all commands but do not execute them")

    p2.set_defaults(func=usb_config)

    # Find adapter sub-command
    p3 = subsubparsers.add_parser(
        'list',
        aliases=['ls'],
        description="List DVB-S2 adapters",
        help='List DVB-S2 adapters',
        formatter_class=ArgumentDefaultsHelpFormatter)
    p3.set_defaults(func=list_subcommand)

    # Remove adapter sub-command
    p4 = subsubparsers.add_parser(
        'remove',
        aliases=['rm'],
        description="Remove DVB-S2 adapter",
        help='Remove DVB-S2 adapter',
        formatter_class=ArgumentDefaultsHelpFormatter)
    p4.add_argument('--all',
                    default=False,
                    action='store_true',
                    help='Remove all dvbnet interfaces associated with the '
                    'adapter')
    p4.add_argument("--dry-run",
                    action='store_true',
                    default=False,
                    help="Print all commands but do not execute them")
    p4.set_defaults(func=rm_subcommand)

    return p
def subparser ( subparsers ) : p = subparsers . add_parser ( 'usb' , description = "USB DVB-S2 receiver manager" , help = 'Manage Linux USB DVB-S2 receiver' , formatter_class = ArgumentDefaultsHelpFormatter ) # Common parameters p . add_argument ( '-a' , '--adapter' , default = None , help = 'DVB-S2 adapter number or model' ) p . add_argument ( '-f' , '--frontend' , default = None , help = 'DVB-S2 adapter\'s frontend number' ) p . set_defaults ( func = print_help ) subsubparsers = p . add_subparsers ( title = 'subcommands' , help = 'Target sub-command' ) # Launch p1 = subsubparsers . add_parser ( 'launch' , description = "Launch a USB DVB-S2 receiver" , help = 'Launch a Linux USB DVB-S2 receiver' , formatter_class = ArgumentDefaultsHelpFormatter ) p1 . add_argument ( '-l' , '--lnb' , choices = defs . lnb_options , default = None , metavar = '' , help = "LNB being used. If not specified, it will be defined " "automatically. Choose from the following LNBs supported " "by v4l-utils: " + ", " . join ( defs . lnb_options ) ) p1 . add_argument ( '-r' , '--record-file' , default = None , help = 'Record MPEG-TS traffic into a target file' ) p1 . add_argument ( '-t' , '--timeout' , default = None , help = 'Stop zapping after a timeout in seconds - useful to \
                    control recording time' ) p1 . add_argument ( '-m' , '--monitor' , default = False , action = 'store_true' , help = 'Launch dvbv5-zap in monitor mode to debug MPEG TS ' 'packet and bit rates' ) monitoring . add_to_parser ( p1 ) p1 . set_defaults ( func = launch ) # Initial configurations p2 = subsubparsers . add_parser ( 'config' , aliases = [ 'cfg' ] , description = 'Initial configurations' , help = 'Configure DVB-S2 interface(s) and\
                                  the host' , formatter_class = ArgumentDefaultsHelpFormatter ) p2 . add_argument ( '-U' , '--ule' , default = False , action = 'store_true' , help = 'Use ULE encapsulation instead of MPE' ) p2 . add_argument ( '--skip-rp' , default = False , action = 'store_true' , help = 'Skip settting of reverse path filters' ) p2 . add_argument ( '--skip-firewall' , default = False , action = 'store_true' , help = 'Skip configuration of firewall rules' ) p2 . add_argument ( '--pid' , default = defs . pids , type = int , nargs = '+' , help = 'List of PIDs to be listened to by dvbnet' ) p2 . add_argument ( '-i' , '--ip' , default = None , nargs = '+' , help = 'IP address set for each DVB-S2 net \
                    interface with subnet mask in CIDR notation' ) p2 . add_argument ( '-y' , '--yes' , default = False , action = 'store_true' , help = "Default to answering Yes to configuration prompts" ) p2 . add_argument ( "--dry-run" , action = 'store_true' , default = False , help = "Print all commands but do not execute them" ) p2 . set_defaults ( func = usb_config ) # Find adapter sub-command p3 = subsubparsers . add_parser ( 'list' , aliases = [ 'ls' ] , description = "List DVB-S2 adapters" , help = 'List DVB-S2 adapters' , formatter_class = ArgumentDefaultsHelpFormatter ) p3 . set_defaults ( func = list_subcommand ) # Remove adapter sub-command p4 = subsubparsers . add_parser ( 'remove' , aliases = [ 'rm' ] , description = "Remove DVB-S2 adapter" , help = 'Remove DVB-S2 adapter' , formatter_class = ArgumentDefaultsHelpFormatter ) p4 . add_argument ( '--all' , default = False , action = 'store_true' , help = 'Remove all dvbnet interfaces associated with the ' 'adapter' ) p4 . add_argument ( "--dry-run" , action = 'store_true' , default = False , help = "Print all commands but do not execute them" ) p4 . set_defaults ( func = rm_subcommand ) return p