(args)
Remove DVB interface
Remove DVB interface
Remove DVB interface
def rm_subcommand(args):
    """Remove DVB interface

    """

    if (not dependencies.check_apps(["dvbnet", "dvb-fe-tool", "ip"])):
        return

    # Configure the subprocess runner
    runner.set_dry(args.dry_run)

    # Find adapter
    if (args.adapter is None):
        adapter, _ = _find_adapter()
    else:
        # If argument --adapter holds a digit-only string, assume it refers to
        # the adapter number. Otherwise, assume it refers to the target model.
        adapter = args.adapter if args.adapter.isdigit() else \
            _find_adapter(target_model=args.adapter)[0]

    interfaces = _find_dvbnet_interfaces(adapter)
    chosen_devices = list()

    if (len(interfaces) > 1):
        if (args.all):
            for interface in interfaces:
                chosen_devices.append(interface['name'])
        else:
            print("Choose net device to remove:")
            for i_dev, interface in enumerate(interfaces):
                print("[%2u] %s" % (i_dev, interface['name']))
            print("[ *] all")

            try:
                choice = input("Choose number: ")
                if (choice == "*"):
                    i_chosen_devices = range(0, len(interfaces))
                else:
                    i_chosen_devices = [int(choice)]
            except ValueError:
                raise ValueError(
                    "Please choose a number or \"*\" for all devices")

            for i_chosen_dev in i_chosen_devices:
                if (i_chosen_dev > len(interfaces)):
                    raise ValueError("Invalid number")

                chosen_devices.append(interfaces[i_chosen_dev]['name'])

    elif (len(interfaces) == 0):
        print("No DVB network interfaces to remove")
        return
    else:
        # There is a single interface
        chosen_devices.append(interfaces[0]['name'])

    for chosen_dev in chosen_devices:
        _rm_dvbnet_interface(adapter, chosen_dev)
def rm_subcommand ( args ) : if ( not dependencies . check_apps ( [ "dvbnet" , "dvb-fe-tool" , "ip" ] ) ) : return # Configure the subprocess runner runner . set_dry ( args . dry_run ) # Find adapter if ( args . adapter is None ) : adapter , _ = _find_adapter ( ) else : # If argument --adapter holds a digit-only string, assume it refers to # the adapter number. Otherwise, assume it refers to the target model. adapter = args . adapter if args . adapter . isdigit ( ) else _find_adapter ( target_model = args . adapter ) [ 0 ] interfaces = _find_dvbnet_interfaces ( adapter ) chosen_devices = list ( ) if ( len ( interfaces ) > 1 ) : if ( args . all ) : for interface in interfaces : chosen_devices . append ( interface [ 'name' ] ) else : print ( "Choose net device to remove:" ) for i_dev , interface in enumerate ( interfaces ) : print ( "[%2u] %s" % ( i_dev , interface [ 'name' ] ) ) print ( "[ *] all" ) try : choice = input ( "Choose number: " ) if ( choice == "*" ) : i_chosen_devices = range ( 0 , len ( interfaces ) ) else : i_chosen_devices = [ int ( choice ) ] except ValueError : raise ValueError ( "Please choose a number or \"*\" for all devices" ) for i_chosen_dev in i_chosen_devices : if ( i_chosen_dev > len ( interfaces ) ) : raise ValueError ( "Invalid number" ) chosen_devices . append ( interfaces [ i_chosen_dev ] [ 'name' ] ) elif ( len ( interfaces ) == 0 ) : print ( "No DVB network interfaces to remove" ) return else : # There is a single interface chosen_devices . append ( interfaces [ 0 ] [ 'name' ] ) for chosen_dev in chosen_devices : _rm_dvbnet_interface ( adapter , chosen_dev )