! Get a dict, USBID -> device, for a device class
        @param device_type The type of devices to search. For exmaple, "serial"
          looks for all serial devices connected to this computer
        @return A dict: Device USBID -> device file in /dev
763913
def _dev_by_id(self, device_type):
        
        dir = os.path.join("/dev", device_type, "by-id")
        if os.path.isdir(dir):
            to_ret = dict(
                self._hex_ids([os.path.join(dir, f) for f in os.listdir(dir)])
            )
            return to_ret
        else:
            logger.error(
                "Could not get %s devices by id. "
                "This could be because your Linux distribution "
                "does not use udev, or does not create /dev/%s/by-id "
                "symlinks. Please submit an issue to github.com/"
                "armmbed/mbed-ls.",
                device_type,
                device_type,
            )
            return {}
560486
def get_dfu_devices(*args, **kwargs):
    
    # convert to list for compatibility with newer pyusb
    return list(usb.core.find(*args, find_all=True,
                              custom_match=FilterDFU(), **kwargs))
55942
public static List<OpenCLDevice> listDevices(TYPE type) {
      final OpenCLPlatform platform = new OpenCLPlatform(0, null, null, null);
      final ArrayList<OpenCLDevice> results = new ArrayList<>();

      for (final OpenCLPlatform p : platform.getOpenCLPlatforms()) {
         for (final OpenCLDevice device : p.getOpenCLDevices()) {
            if (type == null || device.getType() == type) {
               results.add(device);
            }
         }
      }

      return results;
   }
164598
def get(self, device_id: int) -> Optional[Device]:
        """"""
        return self._devices.get(device_id)
1292263
def get_usb_serial(self, port_num):
    

    port = self.port_map[str(port_num)]
    arg = ''.join(['DEVICE INFO,', self._addr, '.', port])
    cmd = (['esuit64', '-t', arg])
    info = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
    serial = None
    if "SERIAL" in info:
      serial_info = info.split('SERIAL:')[1]
      serial = serial_info.split('\n')[0].strip()
      use_info = info.split('BY')[1].split(' ')[1]
      if use_info == 'NO':
        cmd = (['esuit64', '-t', 'AUTO USE ALL'])
        subprocess.check_output(cmd, stderr=subprocess.STDOUT)
        time.sleep(50.0/1000.0)
    else:
      raise ValueError('No USB device detected')
    return serial
607728
def plugged_usbs(multiple=True) -> map or dict:
    

    class FindPenDrives(object):
        # From https://github.com/pyusb/pyusb/blob/master/docs/tutorial.rst
        def __init__(self, class_):
            self._class = class_

        def __call__(self, device):
            # first, let's check the device
            if device.bDeviceClass == self._class:
                return True
            # ok, transverse all devices to find an
            # interface that matches our class
            for cfg in device:
                # find_descriptor: what's it?
                intf = usb.util.find_descriptor(cfg, bInterfaceClass=self._class)
                if intf is not None:
                    try:
                        product = intf.device.product.lower()
                    except ValueError as e:
                        if 'langid' in str(e):
                            raise OSError('Cannot get "langid". Do you have permissions?')
                        else:
                            raise e
                    if 'crw' not in product and 'reader' not in product:
                        return True
            return False

    def get_pendrive(pen: usb.Device) -> dict:
        manufacturer = pen.manufacturer.strip() or str(pen.idVendor)
        model = pen.product.strip() or str(pen.idProduct)
        serial_number = pen.serial_number.strip()
        hid = Naming.hid(manufacturer, serial_number, model)
        return {
            '_id': hid,  # Make live easier to DeviceHubClient by using _id
            'hid': hid,
            '@type': 'USBFlashDrive',
            'serialNumber': serial_number,
            'model': model,
            'manufacturer': manufacturer,
            'vendorId': pen.idVendor,
            'productId': pen.idProduct
        }

    result = usb.core.find(find_all=multiple, custom_match=FindPenDrives(CLASS_MASS_STORAGE))
    if multiple:
        return map(get_pendrive, result)
    else:
        if not result:
            raise NoUSBFound()
        return get_pendrive(result)
809088
def device_typename(item):
        

        dev_type = {'ROUTER': {'from': 'ROUTER',
                               'desc': 'Router',
                               'type': 'Router',
                               'label_x': 19.5},
                    'QEMU': {'from': 'QEMU',
                             'desc': 'QEMU VM',
                             'type': 'QemuVM',
                             'ext_conf': 'QemuDevice',
                             'label_x': -12},
                    'ASA': {'from': 'ASA',
                            'desc': 'QEMU VM',
                            'type': 'QemuVM',
                            'ext_conf': '5520',
                            'label_x': 2.5},
                    'PIX': {'from': 'PIX',
                            'desc': 'QEMU VM',
                            'type': 'QemuVM',
                            'ext_conf': '525',
                            'label_x': -12},
                    'JUNOS': {'from': 'JUNOS',
                              'desc': 'QEMU VM',
                              'type': 'QemuVM',
                              'ext_conf': 'O-series',
                              'label_x': -12},
                    'IDS': {'from': 'IDS',
                            'desc': 'QEMU VM',
                            'type': 'QemuVM',
                            'ext_conf': 'IDS-4215',
                            'label_x': -12},
                    'VBOX': {'from': 'VBOX',
                             'desc': 'VirtualBox VM',
                             'type': 'VirtualBoxVM',
                             'ext_conf': 'VBoxDevice',
                             'label_x': -4.5},
                    'FRSW': {'from': 'FRSW',
                             'desc': 'Frame Relay switch',
                             'type': 'FrameRelaySwitch',
                             'label_x': 7.5},
                    'ETHSW': {'from': 'ETHSW',
                              'desc': 'Ethernet switch',
                              'type': 'EthernetSwitch',
                              'label_x': 15.5},
                    'Hub': {'from': 'Hub',
                            'desc': 'Ethernet hub',
                            'type': 'EthernetHub',
                            'label_x': 12.0},
                    'ATMSW': {'from': 'ATMSW',
                              'desc': 'ATM switch',
                              'type': 'ATMSwitch',
                              'label_x': 2.0},
                    'ATMBR': {'from': 'ATMBR',  # TODO: Investigate ATM Bridge
                              'desc': 'ATMBR',
                              'type': 'ATMBR'},
                    'Cloud': {'from': 'Cloud',
                              'desc': 'Cloud',
                              'type': 'Cloud',
                              'label_x': 47.5}}

        item_type = item.split(' ')[0]
        name = item.replace('%s ' % dev_type[item_type]['from'], '')
        return name, dev_type[item_type]
97209
def get_device_address(usb_device):
        
        try:
            usb_device.ctrl_transfer(0x21, 0x09, 0x0300, 0, GrizzlyUSB.COMMAND_GET_ADDR)
            internal_addr = usb_device.ctrl_transfer(0xa1, 0x01, 0x0301, 0, 2)[1]
            return internal_addr >> 1
        except usb.USBError as e:
            return GrizzlyUSB.USB_DEVICE_ERROR
846728
def devices(self):
        """"""
        params = {'access_token': self.access_token}
        r = self.spark_api.GET(params=params, timeout=self.timeout)
        self._check_error(r)
        json_list = r.json()

        devices_dict = {}
        if json_list:
            # it is possible the keys in json responses varies from one device to another: compute the set of all keys
            allKeys = {'functions', 'variables', 'api', 'requires_deep_update', 'status'} # added by device_info
            for device_json in json_list:
                allKeys.update(device_json.keys())

            Device = _BaseDevice.make_device_class(self, allKeys, timeout = self.timeout)
                    
            for d in json_list:
                if d["connected"]:
                    info = self._get_device_info(d['id'])
                    d['functions'] = info.get('functions')
                    d['variables'] = info.get('variables')
                    d['api'] = self.spark_api(d['id'])
                    d['requires_deep_update'] = d.get('requires_deep_update', False)
                    d['status'] = info.get('status')
                # ensure the set of all keys is present in the dictionnary (Device constructor requires all keys present)
                [d.setdefault(key, None) for key in allKeys]

                devices_dict[d['name']] = Device(**d)
                
        return devices_dict
427473
def get_device_by_id(self, device_id):
        

        # Find the device for the vera device name we are interested in
        found_device = None
        for device in self.get_devices():
            if device.device_id == device_id:
              found_device = device
              # found the first (and should be only) one so we will finish
              break

        if found_device is None:
            logger.debug('Did not find device with {}'.format(device_id))

        return found_device
1208077
public ApiResponse<DeviceTypeEnvelope> getDeviceTypeWithHttpInfo(String deviceTypeId) throws ApiException {
        com.squareup.okhttp.Call call = getDeviceTypeValidateBeforeCall(deviceTypeId, null, null);
        Type localVarReturnType = new TypeToken<DeviceTypeEnvelope>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }
171632
def getDevice(self, id):
        
        return next(iter([d for d in self.devices.values() if d.deviceId == id]), None)
44020
def get_all_usb_devices(idVendor, idProduct):
        
        all_dev = list(usb.core.find(find_all = True, idVendor = idVendor, idProduct = idProduct))
        for dev in all_dev:
            try:
                dev.detach_kernel_driver(0)
            except usb.USBError:
                pass
        return all_dev
1355576
def get_parent_device(self):
        """"""
        if not self.parent_instance_id:
            return ""
        dev_buffer_type = winapi.c_tchar * MAX_DEVICE_ID_LEN
        dev_buffer = dev_buffer_type()
        try:
            if winapi.CM_Get_Device_ID(self.parent_instance_id, byref(dev_buffer),
                    MAX_DEVICE_ID_LEN, 0) == 0: #success
                return dev_buffer.value
            return ""
        finally:
            del dev_buffer
            del dev_buffer_type
1246239
def _get_devices(params):
    '''
    
    '''
    if 'id' not in params:
        raise CommandExecutionError("Parameter ID is required.")

    return type(params['id']) == int and [params['id']] \
           or [int(dev) for dev in params['id'].split(",")]
591515
public java.lang.String getDeviceType() {
    java.lang.Object ref = deviceType_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = 
          (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      deviceType_ = s;
      return s;
    }
  }
1086533
def get_device_event(self, device_event_id):
        
        api = self._get_api(device_directory.DefaultApi)
        return DeviceEvent(api.device_log_retrieve(device_event_id))