Filter a HID device list by current object parameters. Devices
        must match the all of the filtering parameters
767548
def get_devices(self, hid_filter = None):
        
        if not hid_filter: #empty list or called without any parameters
            if type(hid_filter) == type(None):
                #request to query connected devices
                hid_filter = find_all_hid_devices()
            else:
                return hid_filter
        #initially all accepted
        results = {}.fromkeys(hid_filter)

        #the filter parameters
        validating_attributes = list(self.filter_params.keys())

        #first filter out restricted access devices
        if not len(results):
            return {}

        for device in list(results.keys()):
            if not device.is_active():
                del results[device]

        if not len(results):
            return {}

        #filter out
        for item in validating_attributes:
            if item.endswith("_includes"):
                item = item[:-len("_includes")]
            elif item.endswith("_mask"):
                item = item[:-len("_mask")]
            elif item +"_mask" in self.filter_params or item + "_includes" \
                    in self.filter_params:
                continue # value mask or string search is being queried
            elif item not in HidDevice.filter_attributes:
                continue # field does not exist sys.error.write(...)
            #start filtering out
            for device in list(results.keys()):
                if not hasattr(device, item):
                    del results[device]
                elif item + "_mask" in validating_attributes:
                    #masked value
                    if getattr(device, item) & self.filter_params[item + \
                            "_mask"] != self.filter_params[item] \
                            & self.filter_params[item + "_mask"]:
                        del results[device]
                elif item + "_includes" in validating_attributes:
                    #subset item
                    if self.filter_params[item + "_includes"] not in \
                            getattr(device, item):
                        del results[device]
                else:
                    #plain comparison
                    if getattr(device, item) != self.filter_params[item]:
                        del results[device]
            #
        return list(results.keys())
113995
def _find_devices():
    
    ret = []

    logger.info('Looking for devices....')

    if pyusb1:
        for d in usb.core.find(idVendor=USB_VID, idProduct=USB_PID, find_all=1,
                               backend=pyusb_backend):
            ret.append(d)
    else:
        busses = usb.busses()
        for bus in busses:
            for device in bus.devices:
                if device.idVendor == USB_VID:
                    if device.idProduct == USB_PID:
                        ret += [device, ]

    return ret
487118
def get_filtered_devices(
        self, model_name, device_types="upnp:rootdevice", timeout=2
    ):
        

        # get list of all UPNP devices in the network
        upnp_devices = self.discover_upnp_devices(st=device_types)

        # go through all UPNP devices and filter wanted devices
        filtered_devices = collections.defaultdict(dict)
        for dev in upnp_devices.values():
            try:
                # download XML file with information about the device
                # from the device's location
                r = requests.get(dev.location, timeout=timeout)

                if r.status_code == requests.codes.ok:
                    # parse returned XML
                    root = ET.fromstring(r.text)

                    # add shortcut for XML namespace to access sub nodes
                    ns = {"upnp": "urn:schemas-upnp-org:device-1-0"}

                    # get device element
                    device = root.find("upnp:device", ns)

                    if model_name in device.find(
                        "upnp:modelName", ns
                    ).text:
                        # model name is wanted => add to list

                        # get unique UDN of the device that is used as key
                        udn = device.find("upnp:UDN", ns).text

                        # add url base
                        url_base = root.find("upnp:URLBase", ns)
                        if url_base is not None:
                            filtered_devices[udn][
                                "URLBase"
                            ] = url_base.text

                        # add interesting device attributes and
                        # use unique UDN as key
                        for attr in (
                            "deviceType", "friendlyName", "manufacturer",
                            "manufacturerURL", "modelDescription",
                            "modelName", "modelNumber"
                        ):
                            el = device.find("upnp:%s" % attr, ns)
                            if el is not None:
                                filtered_devices[udn][
                                    attr
                                ] = el.text.strip()

            except ET.ParseError:
                # just skip devices that are invalid xml
                pass
            except requests.exceptions.ConnectTimeout:
                # just skip devices that are not replying in time
                print("Timeout for '%s'. Skipping." % dev.location)

        return filtered_devices
782463
def filter_data(data, filter_dict):
    
    for key, match_string in filter_dict.items():
        if key not in data:
            logger.warning("{0} doesn't match a top level key".format(key))
            continue
        values = data[key]
        matcher = re.compile(match_string)
        if isinstance(values, list):
            values = [v for v in values if matcher.search(v)]
        elif isinstance(values, dict):
            values = dict((k, v) for k, v in values.items() if matcher.search(k))
        else:
            raise MiuraException("cannot filter a {0}".format(type(values)))
        data[key] = values
1032705
def list_devices():
    
    devices = []
    all_hids = hid.find_all_hid_devices()
    if all_hids:
        for index, device in enumerate(all_hids):
            for device_name,spec in device_specs.items():
                if device.vendor_id == spec.hid_id[0] and device.product_id == spec.hid_id[1]:
                    devices.append(device_name)                        
    return devices
626920
def _hid_enumerate(vendor_id=0, product_id=0):
    
    start = hidapi.hid_enumerate(vendor_id, product_id)
    result = []
    cur = ffi.new("struct hid_device_info*");
    cur = start

    # Copy everything into python list
    while cur != ffi.NULL:
        result.append(HIDDevice(cur))
        cur = cur.next

    # Free the C memory
    hidapi.hid_free_enumeration(start)

    return result
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
165020
def filter(self, table, volume_types, filter_string):
        """"""
        query = filter_string.lower()
        return [volume_type for volume_type in volume_types
                if query in volume_type.name.lower()]
1034983
def obtain_all_devices(my_devices):
    """"""
    new_devices = {}
    for device_name, device_or_group in my_devices.items():
        # Skip any groups
        if not isinstance(device_or_group, list):
            new_devices[device_name] = device_or_group
    return new_devices
522003
public static device_profile[] get_filtered(nitro_service service, String filter) throws Exception
	{
		device_profile obj = new device_profile();
		options option = new options();
		option.set_filter(filter);
		device_profile[] response = (device_profile[]) obj.getfiltered(service, option);
		return response;
	}
408118
def get_devices(self, category_filter=''):
        
        # pylint: disable=too-many-branches

        # the Vera rest API is a bit rough so we need to make 2 calls to get
        # all the info e need
        self.get_simple_devices_info()

        j = self.data_request({'id': 'status', 'output_format': 'json'}).json()

        self.devices = []
        items = j.get('devices')

        for item in items:
            item['deviceInfo'] = self.device_id_map.get(item.get('id'))
            if item.get('deviceInfo'):
                device_category = item.get('deviceInfo').get('category')
                if device_category == CATEGORY_DIMMER:
                    device = VeraDimmer(item, self)
                elif ( device_category == CATEGORY_SWITCH or
                       device_category == CATEGORY_VERA_SIREN):
                    device = VeraSwitch(item, self)
                elif device_category == CATEGORY_THERMOSTAT:
                    device = VeraThermostat(item, self)
                elif device_category == CATEGORY_LOCK:
                    device = VeraLock(item, self)
                elif device_category == CATEGORY_CURTAIN:
                    device = VeraCurtain(item, self)
                elif device_category == CATEGORY_ARMABLE:
                    device = VeraBinarySensor(item, self)
                elif (device_category == CATEGORY_SENSOR or
                      device_category == CATEGORY_HUMIDITY_SENSOR or
                      device_category == CATEGORY_TEMPERATURE_SENSOR or
                      device_category == CATEGORY_LIGHT_SENSOR or
                      device_category == CATEGORY_POWER_METER or
                      device_category == CATEGORY_UV_SENSOR):
                    device = VeraSensor(item, self)
                elif (device_category == CATEGORY_SCENE_CONTROLLER or
                      device_category == CATEGORY_REMOTE):
                    device = VeraSceneController(item, self)
                elif device_category == CATEGORY_GARAGE_DOOR:
                    device = VeraGarageDoor(item, self)
                else:
                    device = VeraDevice(item, self)
                self.devices.append(device)
                if (device.is_armable and not (
                    device_category == CATEGORY_SWITCH or
                    device_category == CATEGORY_VERA_SIREN or
                    device_category == CATEGORY_CURTAIN or
                    device_category == CATEGORY_GARAGE_DOOR)):
                    self.devices.append(VeraArmableDevice(item, self))
            else:
                self.devices.append(VeraDevice(item, self))

        if not category_filter:
            return self.devices

        devices = []
        for device in self.devices:
            if (device.category_name is not None and
                    device.category_name != '' and
                    device.category_name in category_filter):
                devices.append(device)
        return devices
42045
def filter(self, table, keypairs, filter_string):
        """"""
        query = filter_string.lower()
        return [keypair for keypair in keypairs
                if query in keypair.name.lower()]
1295830
def register_hid_device(screen_width, screen_height,
                        absolute=False, integrated_display=False):
    """"""
    message = create(protobuf.REGISTER_HID_DEVICE_MESSAGE)
    descriptor = message.inner().deviceDescriptor
    descriptor.absolute = 1 if absolute else 0
    descriptor.integratedDisplay = 1 if integrated_display else 0
    descriptor.screenSizeWidth = screen_width
    descriptor.screenSizeHeight = screen_height
    return message
230203
def getDevices(self, status=None):
        
        return [d for d in self.devices.values() if status is None or d.payload.get('status') == status]
309758
def get_all_connected_interfaces():
        

        devices = hid.enumerate()

        if not devices:
            log.debug("No Mbed device connected")
            return []

        boards = []

        for deviceInfo in devices:
            product_name = to_str_safe(deviceInfo['product_string'])
            if (product_name.find("CMSIS-DAP") < 0):
                # Skip non cmsis-dap devices
                continue
            
            vid = deviceInfo['vendor_id']
            pid = deviceInfo['product_id']
            
            # Perform device-specific filtering.
            if filter_device_by_usage_page(vid, pid, deviceInfo['usage_page']):
                continue

            try:
                dev = hid.device(vendor_id=vid, product_id=pid, path=deviceInfo['path'])
            except IOError as exc:
                log.debug("Failed to open USB device: %s", exc)
                continue

            # Create the USB interface object for this device.
            new_board = HidApiUSB()
            new_board.vendor_name = deviceInfo['manufacturer_string']
            new_board.product_name = deviceInfo['product_string']
            new_board.serial_number = deviceInfo['serial_number']
            new_board.vid = vid
            new_board.pid = pid
            new_board.device_info = deviceInfo
            new_board.device = dev
            boards.append(new_board)

        return boards
1227282
def list_devices():
    
    output = {}
    for device_id, device in devices.items():
        output[device_id] = {
            'host': device.host,
            'state': device.state
        }
    return jsonify(devices=output)
505359
def list_devices(names=None, continue_from=None, **kwargs):
    """"""

    if not names:
        names = [device for device, _type in settings.GOLDEN_DEVICES if _type == 'OpenThread']

    if continue_from:
        continue_from = names.index(continue_from)
    else:
        continue_from = 0

    for port in names[continue_from:]:
        try:
            with OpenThreadController(port) as otc:
                print('%s: %s' % (port, otc.version))
        except:
            logger.exception('failed to get version of %s' % port)