def __init__(self, device, setting, name=None, default_timeout_ms=None):
    super(LibUsbHandle, self).__init__(device.getSerialNumber(), name=name,
                                       default_timeout_ms=default_timeout_ms)
    self._setting = setting
    self._device = device

    self._read_endpoint = None
    self._write_endpoint = None
    self._handle = None

    for endpoint in self._setting.iterEndpoints():
      address = endpoint.getAddress()
      if address & libusb1.USB_ENDPOINT_DIR_MASK == libusb1.LIBUSB_ENDPOINT_IN:
        if self._read_endpoint is not None:
          raise usb_exceptions.InvalidEndpointsError(
              'Multiple in endpoints found')
        self._read_endpoint = address
      else:
        if self._write_endpoint is not None:
          raise usb_exceptions.InvalidEndpointsError(
              'Multiple out endpoints found')
        self._write_endpoint = address

    if self._read_endpoint is None:
      raise usb_exceptions.InvalidEndpointsError('Missing in endpoint')
    if self._write_endpoint is None:
      raise usb_exceptions.InvalidEndpointsError('Missing out endpoint')

    handle = self._device.open()
    iface_number = self._setting.getNumber()
    try:
      if handle.kernelDriverActive(iface_number):
        handle.detachKernelDriver(iface_number)
    except libusb1.USBError as exception:
      if exception.value == libusb1.LIBUSB_ERROR_NOT_FOUND:
        _LOG.warning('Kernel driver not found for interface: %s.', iface_number)
      else:
        raise usb_exceptions.LibusbWrappingError(
            exception, '%s failed to detach kernel driver', self)
    # Try to claim the interface, if the device is gone, raise an IOError
    try:
      handle.claimInterface(iface_number)
    except libusb1.USBError as exception:
      raise usb_exceptions.LibusbWrappingError(
          exception, '%s failed to claim interface: %d', self, iface_number)

    self._handle = handle
    self._interface_number = iface_number
Interpolates s with args/kwarg and prints on stderr, when debug == True.
dataset/ETHPy150Open google/openhtf/openhtf/plugs/usb/local_usb.py/LibUsbHandle.__init__--crossover with--dataset/ETHPy150Open philipbergen/zero/py/zero/__init__.py/ZeroSetup._print