Create and return device.

    :type args: object
    :type display_types: dict
514577
def create_device(args, display_types=None):
    
    device = None
    if display_types is None:
        display_types = get_display_types()

    if args.display in display_types.get('oled'):
        import luma.oled.device
        Device = getattr(luma.oled.device, args.display)
        Serial = getattr(make_serial(args), args.interface)
        device = Device(Serial(), **vars(args))

    elif args.display in display_types.get('lcd'):
        import luma.lcd.device
        import luma.lcd.aux
        Device = getattr(luma.lcd.device, args.display)
        spi = make_serial(args).spi()
        device = Device(spi, **vars(args))
        luma.lcd.aux.backlight(gpio=spi._gpio, gpio_LIGHT=args.gpio_backlight, active_low=args.backlight_active == "low").enable(True)

    elif args.display in display_types.get('led_matrix'):
        import luma.led_matrix.device
        from luma.core.interface.serial import noop
        Device = getattr(luma.led_matrix.device, args.display)
        spi = make_serial(args, gpio=noop()).spi()
        device = Device(serial_interface=spi, **vars(args))

    elif args.display in display_types.get('emulator'):
        import luma.emulator.device
        Device = getattr(luma.emulator.device, args.display)
        device = Device(**vars(args))

    return device
739548
def init_device(**kwargs):
    
    new_device = OCLDevice(**kwargs)

    # just change globals if new_device is different from old
    if _ocl_globals.device.device != new_device.device:
        _ocl_globals.device = new_device
236139
def get_device(self, device_id, refresh=False):
        """"""
        if self._devices is None:
            self.get_devices()
            refresh = False

        device = self._devices.get(device_id)

        if device and refresh:
            device.refresh()

        return device
1171934
def _ipython_display_(self):
        """"""
        from IPython.display import display

        self.build_widget()
        display(self.widget())
107746
def write_display(self):
        """"""
        for i, value in enumerate(self.buffer):
            self._device.write8(i, value)
290494
def device_class(self, device_class):
        
        if device_class is not None and len(device_class) > 32:
            raise ValueError("Invalid value for `device_class`, length must be less than or equal to `32`")

        self._device_class = device_class
529272
def type(self):
        
        if self._device_mode == 1 or self._type == CertificateType.developer:
            return CertificateType.developer
        elif self._type == CertificateType.bootstrap:
            return CertificateType.bootstrap
        else:
            return CertificateType.lwm2m
200446
def open(self):
        
        
        self.device = usb.core.find(idVendor=self.idVendor, idProduct=self.idProduct)
        if self.device is None:
            raise NoDeviceError()
        try:
            if self.device.is_kernel_driver_active(self.interface):
                self.device.detach_kernel_driver(self.interface) 
            self.device.set_configuration()
            usb.util.claim_interface(self.device, self.interface)
        except usb.core.USBError as e:
            raise HandleDeviceError(e)
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(",")]
172000
def newDevice(deviceJson, lupusec):
    """"""
    type_tag = deviceJson.get('type')

    if not type_tag:
        _LOGGER.info('Device has no type')

    if type_tag in CONST.TYPE_OPENING:
        return LupusecBinarySensor(deviceJson, lupusec)
    elif type_tag in CONST.TYPE_SENSOR:
        return LupusecBinarySensor(deviceJson, lupusec)
    elif type_tag in CONST.TYPE_SWITCH:
        return LupusecSwitch(deviceJson, lupusec)
    else:
        _LOGGER.info('Device is not known')
    return None
871349
def new_device(self, name, type):
        
        # at least android client also includes a "cid" with is derived from the unique device id
        # and encrypted with a public key in the apk.  The field appears to be optional
        url = posixpath.join(self.rootpath, name)
        r = self.post(url, {'type': type})
        return r
1207795
def create_device(device_args):
    
    device = AlarmDecoder(USBDevice.find(device_args))
    device.on_message += handle_message
    device.open()

    return device
78891
def switchDisplay(self, display):
        
        if display in self.displays:
            self.setWidget(self.displays[display])
            self._current = display
        else:
            raise Exception("Undefined display type "+ display)
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;
   }
501943
def device(self, device_id, *args, **kwargs):
        
        return Device(device_id, self.corsair_sdk, self._corsair_sdk_path, *args, **kwargs)
828500
function device() {
  return {
    ua: navigator.userAgent,
    language: (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage),
  };
}
1239256
def eglGetDisplay(display=EGL_DEFAULT_DISPLAY):
    
    res = _lib.eglGetDisplay(display)
    if not res or res == EGL_NO_DISPLAY:
        raise RuntimeError('Could not create display')
    return res