def __getattr__(self, attr): # pylint: disable=invalid-name """Fallthrough to underlying FastbootProtocol handler. Args: attr: Attribute to get. Returns: Either the attribute from the device or a retrying function-wrapper if attr is a method on the device. """ if not self._protocol: raise usb_exceptions.HandleClosedError() val = getattr(self._protocol, attr) if callable(val): def _retry_wrapper(*args, **kwargs): """Wrap the retry function.""" result = _retry_usb_function(self._num_retries, val, *args, **kwargs) _LOG.debug('LIBUSB FASTBOOT: %s(*%s, **%s) -> %s', attr, args, kwargs, result) return result return _retry_wrapper return val
def wrapper_requiring_open_handle(self, *args, **kwargs): """The wrapper to be returned.""" if self.is_closed(): raise usb_exceptions.HandleClosedError() return method(self, *args, **kwargs)