Gives a list of enabled interfaces. Should work on all windows versions.

  Returns:
    interfaces: Names of interfaces found enabled.
189319
def GetEnabledInterfaces():
  
  interfaces = []
  show_args = ['/c', 'netsh', 'show', 'interface']
  # pylint: disable=undefined-variable
  res = client_utils_common.Execute(
      'cmd', show_args, time_limit=-1, bypass_whitelist=True)
  pattern = re.compile(r'\s*')
  for line in res[0].split('\r\n'):  # res[0] is stdout.
    interface_info = pattern.split(line)
    if 'Enabled' in interface_info:
      interfaces.extend(interface_info[-1:])
  return interfaces
1251350
def _get_object_menu_models():
    
    from pyoko.conf import settings
    enabled_models = []
    for entry in settings.OBJECT_MENU.values():
        for mdl in entry:
            if 'wf' not in mdl:
                enabled_models.append(mdl['name'])
    return enabled_models
164452
def get_if_list():
    """"""

    # Get ifconfig output
    try:
        fd = os.popen("%s -a" % conf.prog.ifconfig)
    except OSError as msg:
        raise Scapy_Exception("Failed to execute ifconfig: (%s)" % msg)

    # Get interfaces
    interfaces = [line[:line.find(':')] for line in fd.readlines()
                  if ": flags" in line.lower()]
    return interfaces
553162
def getall(self):
        

        vrrps = dict()

        # Find the available interfaces
        interfaces = re.findall(r'^interface\s(\S+)', self.config, re.M)

        # Get the vrrps defined for each interface
        for interface in interfaces:
            vrrp = self.get(interface)
            # Only add those interfaces that have vrrps defined
            if vrrp:
                vrrps.update({interface: vrrp})

        return vrrps
872526
def get_all_connected_interfaces():
        
        # find all cmsis-dap devices
        all_devices = usb.core.find(find_all=True, custom_match=FindDap())

        # iterate on all devices found
        boards = []
        for board in all_devices:
            new_board = PyUSB()
            new_board.vid = board.idVendor
            new_board.pid = board.idProduct
            new_board.product_name = board.product
            new_board.vendor_name = board.manufacturer
            new_board.serial_number = board.serial_number
            boards.append(new_board)

        return boards
94049
def EnableNetworkInterfaces(self, interfaces):
    
    # The default Ethernet interface is enabled by default. Do not attempt to
    # enable interfaces if only one interface is specified in metadata.
    if not interfaces or set(interfaces) == self.interfaces:
      return

    self.logger.info('Ethernet interfaces: %s.', interfaces)
    self.interfaces = set(interfaces)

    if self.dhcp_command:
      try:
        subprocess.check_call([self.dhcp_command])
      except subprocess.CalledProcessError:
        self.logger.warning('Could not enable Ethernet interfaces.')
      return

    # Distro-specific setup for network interfaces.
    self.distro_utils.EnableNetworkInterfaces(
        interfaces, self.logger, dhclient_script=self.dhclient_script)
420010
def get_interface_by_instance_name(self, name):
        ''''''
        with self._mutex:
            for intf in self.interfaces:
                if intf.instance_name == name:
                    return intf
            return None
724575
def _get_window_list(self):
        
        window_list = Quartz.CGWindowListCopyWindowInfo(Quartz.kCGWindowListExcludeDesktopElements, Quartz.kCGNullWindowID)
        return window_list
1276111
def interfaces(self):
        
        if not self._interfaces_cache:
            response = yield from self.get("/network/interfaces")
            self._interfaces_cache = response.json
        return self._interfaces_cache
694238
def get_disabled():
    '''
    
    '''
    services = []
    for daemon, is_enabled in six.iteritems(_get_rc()):
        if not is_enabled:
            services.append(daemon)
    return sorted(set(get_all()) & set(services))
1301001
def interface(self):
        
        
        # Possible control arguments
        controls = {
            'start': self.do_start,
            'stop': self.do_stop,
            'status': self.do_status,
            'restart': self.do_restart,
            'reload': self.do_restart    
        }
        
        # Process the control argument
        try:
            controls[self.command]()
        except KeyError:
            self.write_stdout('Usage: {} {{start|stop|status|restart|reload}}'.format(self.name), 3)
        exit(0)
11556
def get_all_connected_interfaces():
        
        all_devices = hid.find_all_hid_devices()

        # find devices with good vid/pid
        all_mbed_devices = []
        for d in all_devices:
            if (d.product_name.find("CMSIS-DAP") >= 0):
                all_mbed_devices.append(d)

        boards = []
        for dev in all_mbed_devices:
            try:
                dev.open(shared=True)

                # Perform device-specific filtering.
                if filter_device_by_usage_page(dev.vendor_id, dev.product_id, dev.hid_caps.usage_page):
                    dev.close()
                    continue

                report = dev.find_output_reports()
                if len(report) != 1:
                    dev.close()
                    continue
                new_board = PyWinUSB()
                new_board.report = report[0]
                new_board.vendor_name = dev.vendor_name
                new_board.product_name = dev.product_name
                new_board.serial_number = dev.serial_number
                new_board.vid = dev.vendor_id
                new_board.pid = dev.product_id
                new_board.device = dev
                dev.close()
                boards.append(new_board)
            except Exception as e:
                if (str(e) != "Failure to get HID pre parsed data"):
                    log.error("Receiving Exception: %s", e)
                dev.close()

        return boards
22635
def get_disabled(self):
        
        installed = set(self.get_installed())
        enabled = set(self.get_enabled())
        return sorted(installed - enabled)
371697
def get_windows_interfaces():
    

    import win32com.client
    import pywintypes

    interfaces = []
    try:
        locator = win32com.client.Dispatch("WbemScripting.SWbemLocator")
        service = locator.ConnectServer(".", "root\cimv2")
        network_configs = service.InstancesOf("Win32_NetworkAdapterConfiguration")
        # more info on Win32_NetworkAdapter: http://msdn.microsoft.com/en-us/library/aa394216%28v=vs.85%29.aspx
        for adapter in service.InstancesOf("Win32_NetworkAdapter"):
            if adapter.NetConnectionStatus == 2 or adapter.NetConnectionStatus == 7:
                # adapter is connected or media disconnected
                ip_address = ""
                netmask = ""
                for network_config in network_configs:
                    if network_config.InterfaceIndex == adapter.InterfaceIndex:
                        if network_config.IPAddress:
                            # get the first IPv4 address only
                            ip_address = network_config.IPAddress[0]
                            netmask = network_config.IPSubnet[0]
                        break
                npf_interface = "\\Device\\NPF_{guid}".format(guid=adapter.GUID)
                interfaces.append({"id": npf_interface,
                                   "name": adapter.NetConnectionID,
                                   "ip_address": ip_address,
                                   "mac_address": adapter.MACAddress,
                                   "netcard": adapter.name,
                                   "netmask": netmask,
                                   "type": "ethernet"})
    except (AttributeError, pywintypes.com_error):
        log.warn("Could not use the COM service to retrieve interface info, trying using the registry...")
        return _get_windows_interfaces_from_registry()

    return interfaces
205889
def interfaces(self) -> GraphQLInterfaceList:
        """"""
        try:
            interfaces = resolve_thunk(self._interfaces)
        except GraphQLError:
            raise
        except Exception as error:
            raise TypeError(f"{self.name} interfaces cannot be resolved: {error}")
        if interfaces is None:
            interfaces = []
        if not isinstance(interfaces, (list, tuple)):
            raise TypeError(
                f"{self.name} interfaces must be a list/tuple"
                " or a function which returns a list/tuple."
            )
        if not all(isinstance(value, GraphQLInterfaceType) for value in interfaces):
            raise TypeError(f"{self.name} interfaces must be GraphQLInterface objects.")
        return interfaces[:]
38414
def get_interface(iface):
    '''
    
    '''
    _interfaces = get_interfaces_details()
    for _interface in _interfaces['interfaces']:
        if _interface['connectionid'] == iface:
            return _dict_to_string(_interface)
    return None
449497
def get_interfaces_counters(self):
        """"""
        query = junos_views.junos_iface_counter_table(self.device)
        query.get()
        interface_counters = {}
        for interface, counters in query.items():
            interface_counters[interface] = {
                k: v if v is not None else -1 for k, v in counters
            }
        return interface_counters