From 00ea1287758a237e13933154ae1700837230560d Mon Sep 17 00:00:00 2001 From: effective-light Date: Mon, 10 Aug 2020 03:18:10 -0400 Subject: [PATCH] Prevent the precommit hooks from complaining --- lib/logitech_receiver/__init__.py | 2 +- lib/logitech_receiver/base.py | 2 ++ lib/logitech_receiver/base_usb.py | 7 ++----- lib/logitech_receiver/device.py | 14 ++++++-------- lib/logitech_receiver/receiver.py | 3 +-- lib/solaar/cli/__init__.py | 1 + lib/solaar/cli/show.py | 2 +- 7 files changed, 14 insertions(+), 17 deletions(-) diff --git a/lib/logitech_receiver/__init__.py b/lib/logitech_receiver/__init__.py index 70965dfe..fe9de656 100644 --- a/lib/logitech_receiver/__init__.py +++ b/lib/logitech_receiver/__init__.py @@ -36,9 +36,9 @@ import logging from . import listener, status # noqa: F401 from .base import DeviceUnreachable, NoReceiver, NoSuchDevice # noqa: F401 from .common import strhex # noqa: F401 +from .device import Device # noqa: F401 from .hidpp20 import FeatureCallError, FeatureNotSupported # noqa: F401 from .receiver import Receiver # noqa: F401 -from .device import Device # noqa: F401 _DEBUG = logging.DEBUG _log = logging.getLogger(__name__) diff --git a/lib/logitech_receiver/base.py b/lib/logitech_receiver/base.py index 7a333912..7930e2e8 100644 --- a/lib/logitech_receiver/base.py +++ b/lib/logitech_receiver/base.py @@ -95,11 +95,13 @@ def receivers(): for d in _hid.enumerate(receiver_usb_id): yield d + def wired_devices(): for device_usb_id in _WIRED_DEVICE_IDS: for dev in _hid.enumerate(device_usb_id): yield dev + def notify_on_receivers_glib(callback): """Watch for matching devices and notifies the callback on the GLib thread.""" _hid.monitor_glib(callback, *_RECEIVER_USB_IDS) diff --git a/lib/logitech_receiver/base_usb.py b/lib/logitech_receiver/base_usb.py index af95fbfd..b7aea263 100644 --- a/lib/logitech_receiver/base_usb.py +++ b/lib/logitech_receiver/base_usb.py @@ -99,11 +99,7 @@ _ex100_receiver = lambda product_id: { 'ex100_wpid_fix': True } -_wired_device = lambda product_id: { - 'vendor_id': 0x046d, - 'product_id': product_id, - 'usb_interface': 2 -} +_wired_device = lambda product_id: {'vendor_id': 0x046d, 'product_id': product_id, 'usb_interface': 2} # standard Unifying receivers (marked with the orange Unifying logo) UNIFYING_RECEIVER_C52B = _unifying_receiver(0xc52b) @@ -181,6 +177,7 @@ WIRED_DEVICES = ( WIRED_DEVICE_C091, ) + def product_information(usb_id): if isinstance(usb_id, str): usb_id = int(usb_id, 16) diff --git a/lib/logitech_receiver/device.py b/lib/logitech_receiver/device.py index 45b4b5ea..3a23aa66 100644 --- a/lib/logitech_receiver/device.py +++ b/lib/logitech_receiver/device.py @@ -22,6 +22,7 @@ _R = _hidpp10.REGISTERS # # + class Device(object): read_register = _hidpp10.read_register @@ -76,8 +77,7 @@ class Device(object): if receiver: if link_notification is not None: self.online = not bool(ord(link_notification.data[0:1]) & 0x40) - self.wpid = _strhex(link_notification.data[2:3] - + link_notification.data[1:2]) + self.wpid = _strhex(link_notification.data[2:3] + link_notification.data[1:2]) # assert link_notification.address == (0x04 # if unifying else 0x03) kind = ord(link_notification.data[0:1]) & 0x0F @@ -118,8 +118,7 @@ class Device(object): device_info = self.receiver.read_register(_R.receiver_info, 0x04) if device_info is None: _log.error('failed to read Nano wpid for device %d of %s', number, receiver) - raise _base.NoSuchDevice(number=number, - receiver=receiver, error='read Nano wpid') + raise _base.NoSuchDevice(number=number, receiver=receiver, error='read Nano wpid') self.wpid = _strhex(device_info[3:5]) self._power_switch = '(' + _('unknown') + ')' @@ -322,7 +321,6 @@ class Device(object): def request(self, request_id, *params, no_reply=False): return _base.request(self.handle, self.number, request_id, *params, no_reply=no_reply) - def feature_request(self, feature, function=0x00, *params, no_reply=False): if self.protocol >= 2.0: return _hidpp20.feature_request(self, feature, function, *params, no_reply=no_reply) @@ -352,8 +350,8 @@ class Device(object): __bool__ = __nonzero__ = lambda self: self.wpid is not None and self.number in self.receiver def __str__(self): - return '' % (self.number, - self.wpid or self.product_id, - self.name or self.codename or '?', self.serial) + return '' % ( + self.number, self.wpid or self.product_id, self.name or self.codename or '?', self.serial + ) __unicode__ = __repr__ = __str__ diff --git a/lib/logitech_receiver/receiver.py b/lib/logitech_receiver/receiver.py index 6a57be5d..4db61af2 100644 --- a/lib/logitech_receiver/receiver.py +++ b/lib/logitech_receiver/receiver.py @@ -24,12 +24,11 @@ import errno as _errno from logging import INFO as _INFO from logging import getLogger -from .device import Device - from . import base as _base from . import hidpp10 as _hidpp10 from .base_usb import product_information as _product_information from .common import strhex as _strhex +from .device import Device _log = getLogger(__name__) del getLogger diff --git a/lib/solaar/cli/__init__.py b/lib/solaar/cli/__init__.py index 6d2e812c..f2437ec0 100644 --- a/lib/solaar/cli/__init__.py +++ b/lib/solaar/cli/__init__.py @@ -109,6 +109,7 @@ def _receivers(dev_path=None): _log.exception('opening ' + str(dev_info)) _sys.exit('%s: error: %s' % (NAME, str(e))) + def _wired_devices(dev_path=None): from logitech_receiver import Device from logitech_receiver.base import wired_devices diff --git a/lib/solaar/cli/show.py b/lib/solaar/cli/show.py index ae7ce31e..f9053b41 100644 --- a/lib/solaar/cli/show.py +++ b/lib/solaar/cli/show.py @@ -21,9 +21,9 @@ from __future__ import absolute_import, division, print_function, unicode_litera from logitech_receiver import hidpp10 as _hidpp10 from logitech_receiver import hidpp20 as _hidpp20 +from logitech_receiver import receiver as _receiver from logitech_receiver import settings_templates as _settings_templates from logitech_receiver.common import NamedInt as _NamedInt -from logitech_receiver import receiver as _receiver def _print_receiver(receiver):