'Return the name of a valid interface with modes supplied
:param self: A NetworkManager object
:param has_ap_mode: AP mode support
:param has_monitor_mode: Monitor mode support
:type self: NetworkManager
:type has_ap_mode: bool
:type has_monitor_mode: bool
:return: Name of valid interface
:rtype: str
.. raises InterfaceCantBeFoundError: When an interface with
supplied modes can\'t be found
.. raises InterfaceManagedByNetworkManagerError: When the chosen
interface is managed by NetworkManager
.. note: This method guarantees that an interface with perfect
match will be returned if available'

def get_interface(self, has_ap_mode=False, has_monitor_mode=False):

    possible_adapters = list()
    for (interface, adapter) in self._name_to_object.iteritems():
        if ((interface not in self._active) and (adapter not in possible_adapters)):
            if ((adapter.has_ap_mode == has_ap_mode) and (adapter.has_monitor_mode == has_monitor_mode)):
                possible_adapters.insert(0, adapter)
            elif (has_ap_mode and adapter.has_ap_mode):
                possible_adapters.append(adapter)
            elif (has_monitor_mode and adapter.has_monitor_mode):
                possible_adapters.append(adapter)
    for adapter in possible_adapters:
        if (not adapter.is_managed_by_nm):
            chosen_interface = adapter.name
            self._active.add(chosen_interface)
            return chosen_interface
    if possible_adapters:
        raise InterfaceManagedByNetworkManagerError('ALL')
    else:
        raise InterfaceCantBeFoundError((has_monitor_mode, has_ap_mode))
