Find all devices and events with a given monitor installed.
435798
def _find_monitor(monitors, handle):
    """"""

    found_devs = set()
    found_events = set()

    for conn_string, device in monitors.items():
        for event, handles in device.items():
            if handle in handles:
                found_events.add(event)
                found_devs.add(conn_string)

    return found_devs, found_events
703085
def _get_devices_by_failover_status(self, status):
        '''
        '''

        devices_with_status = []
        for device in self.devices:
            if (self._check_device_failover_status(device, status)):
                devices_with_status.append(device)
        return devices_with_status
307491
function DeviceInfo (deviceIndex, deviceName, deviceType) {
    this.index = deviceIndex;
    this.name = deviceName;
    this.type = deviceType;
}
993733
def print_all_devices():
    """"""
    print("Printing information about all devices paired to the Gateway")
    if len(devices) == 0:
        exit(bold("No devices paired"))

    container = []
    for dev in devices:
        container.append(dev.raw)
    print(jsonify(container))
960528
def devices(self):
        """"""
        if self._all_devices:
            return self._all_devices

        self._all_devices = {}
        self._all_devices['cameras'] = []
        self._all_devices['base_station'] = []

        url = DEVICES_ENDPOINT
        data = self.query(url)

        for device in data.get('data'):
            name = device.get('deviceName')
            if ((device.get('deviceType') == 'camera' or
                 device.get('deviceType') == 'arloq' or
                 device.get('deviceType') == 'arloqs') and
                    device.get('state') == 'provisioned'):
                camera = ArloCamera(name, device, self)
                self._all_devices['cameras'].append(camera)

            if (device.get('state') == 'provisioned' and
                    (device.get('deviceType') == 'basestation' or
                     device.get('modelId') == 'ABC1000')):
                base = ArloBaseStation(name, device, self.__token, self)
                self._all_devices['base_station'].append(base)

        return self._all_devices
796553
def _get_future_devices(self, context):
        """"""
        monitor = Monitor.from_netlink(context)
        monitor.filter_by("hidraw")
        monitor.start()

        self._scanning_log_message()
        for device in iter(monitor.poll, None):
            if device.action == "add":
                # Sometimes udev rules has not been applied at this point,
                # causing permission denied error if we are running in user
                # mode. With this sleep this will hopefully not happen.
                sleep(1)

                yield device
                self._scanning_log_message()
561296
function listenForDevices() {
  console.log('Listening for connected devices... \n');

  usbmux.createListener()
    .on('error', onErr)
    .on('attached', function(udid) {
      console.log('Device found: ', udid);
    })
    .on('detached', function(udid) {
      console.log('Device removed: ', udid);
    });
}
137729
def get_devices(self, refresh=False, generic_type=None):
        """"""
        _LOGGER.info("Updating all devices...")
        if refresh or self._devices is None:
            if self._devices is None:
                self._devices = {}

            responseObject = self.get_sensors()
            if (responseObject and
                    not isinstance(responseObject, (tuple, list))):
                responseObject = responseObject

            for deviceJson in responseObject:
                # Attempt to reuse an existing device
                device = self._devices.get(deviceJson['name'])

                # No existing device, create a new one
                if device:
                    device.update(deviceJson)
                else:
                    device = newDevice(deviceJson, self)

                    if not device:
                        _LOGGER.info('Device is unknown')
                        continue

                    self._devices[device.device_id] = device

            # We will be treating the Lupusec panel itself as an armable device.
            panelJson = self.get_panel()
            _LOGGER.debug("Get the panel in get_devices: %s", panelJson)

            self._panel.update(panelJson)

            alarmDevice = self._devices.get('0')

            if alarmDevice:
                alarmDevice.update(panelJson)
            else:
                alarmDevice = ALARM.create_alarm(panelJson, self)
                self._devices['0'] = alarmDevice

            # Now we will handle the power switches
            switches = self.get_power_switches()
            _LOGGER.debug(
                'Get active the power switches in get_devices: %s', switches)

            for deviceJson in switches:
                # Attempt to reuse an existing device
                device = self._devices.get(deviceJson['name'])

                # No existing device, create a new one
                if device:
                    device.update(deviceJson)
                else:
                    device = newDevice(deviceJson, self)
                    if not device:
                        _LOGGER.info('Device is unknown')
                        continue
                    self._devices[device.device_id] = device

        if generic_type:
            devices = []
            for device in self._devices.values():
                if (device.type is not None and
                        device.type in generic_type[0]):
                    devices.append(device)
            return devices

        return list(self._devices.values())
1242141
def devices(opts=[]):
    
    adb_full_cmd = [v.ADB_COMMAND_PREFIX, v.ADB_COMMAND_DEVICES, _convert_opts(opts)]
    return _exec_command(adb_full_cmd)
1285804
def iter_monitors(self):
        """"""

        for conn_string, events in self._monitors.items():
            for event, handlers in events.items():
                for handler in handlers:
                    yield (conn_string, event, handler)
886202
def _find_devices(serial=None):
    
    ret = []

    if pyusb1:
        for d in usb.core.find(idVendor=0x1915, idProduct=0x7777, find_all=1,
                               backend=pyusb_backend):
            if serial is not None and serial == d.serial_number:
                return d
            ret.append(d)
    else:
        busses = usb.busses()
        for bus in busses:
            for device in bus.devices:
                if device.idVendor == CRADIO_VID:
                    if device.idProduct == CRADIO_PID:
                        if serial == device.serial_number:
                            return device
                        ret += [device, ]

    return ret
739282
def getMonitorById(self, monitorId):
        
        url = self.baseUrl
        url += "getMonitors?apiKey=%s&monitors=%s" % (self.apiKey, monitorId)
        url += "&noJsonCallback=1&format=json"
        success, response = self.requestApi(url)
        if success:
            status = response.get('monitors').get('monitor')[0].get('status')
            alltimeuptimeratio = response.get('monitors').get('monitor')[0].get('alltimeuptimeratio')
            return status, alltimeuptimeratio
        return None, None
1044024
def find_device(vidpid):
    """"""
    for port in list_ports.comports():
        if re.search(vidpid, port[2], flags=re.IGNORECASE):
            return port[0]

    raise exceptions.RoasterLookupError
141896
def show_devices(verbose=False, **kwargs):
    
    kwargs["find_all"] = True
    devices = find(**kwargs)
    strings = ""
    for device in devices:
        if not verbose:
            strings +=  "%s, %s\n" % (device._str(), _try_lookup(
                _lu.device_classes, device.bDeviceClass))
        else:
            strings += "%s\n\n" % str(device)

    return _DescriptorInfo(strings)
291749
def _events(self):
    """"""
    for did, device in sorted(six.iteritems(self._proto.devices)):
      if device.name:
        yield dict(
            ph=_TYPE_METADATA,
            pid=did,
            name='process_name',
            args=dict(name=device.name))
      yield dict(
          ph=_TYPE_METADATA,
          pid=did,
          name='process_sort_index',
          args=dict(sort_index=did))
      for rid, resource in sorted(six.iteritems(device.resources)):
        if resource.name:
          yield dict(
              ph=_TYPE_METADATA,
              pid=did,
              tid=rid,
              name='thread_name',
              args=dict(name=resource.name))
        yield dict(
            ph=_TYPE_METADATA,
            pid=did,
            tid=rid,
            name='thread_sort_index',
            args=dict(sort_index=rid))
    # TODO(sammccall): filtering and downsampling?
    for event in self._proto.trace_events:
      yield self._event(event)
959060
def devices(self):
        """"""
        log_msg = True
        while True:
            if log_msg:
                self.logger.info("Scanning for devices")

            try:
                device = self.find_device()
                if device:
                    yield device
                    log_msg = True
                else:
                    log_msg = False
            except BackendError as err:
                self.logger.error("Error while scanning for devices: {0}",
                                  err)
                return
            except DeviceError as err:
                self.logger.error("Unable to connect to detected device: {0}",
                                  err)
654350
def get_device_elements(self):
        """"""
        plain = self._aha_request('getdevicelistinfos')
        dom = xml.dom.minidom.parseString(plain)
        _LOGGER.debug(dom)
        return dom.getElementsByTagName("device")