Skip to content

Commit

Permalink
logitech_receiver: style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pfps committed Feb 20, 2024
1 parent 5f487dd commit 476f41f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
3 changes: 2 additions & 1 deletion lib/logitech_receiver/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,8 @@ def ping(handle, devnumber, long_message=False):
error = ord(reply_data[3:4])
if error == _hidpp10_constants.ERROR.invalid_SubID__command: # a valid reply from a HID++ 1.0 device
return 1.0
if error == _hidpp10_constants.ERROR.resource_error or error == _hidpp10_constants.ERROR.connection_request_failed:
if error == _hidpp10_constants.ERROR.resource_error or \
error == _hidpp10_constants.ERROR.connection_request_failed:
return # device unreachable
if error == _hidpp10_constants.ERROR.unknown_device: # no paired device with that number
logger.error('(%s) device %d error on ping request: unknown device', handle, devnumber)
Expand Down
15 changes: 8 additions & 7 deletions lib/logitech_receiver/hidpp20.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
from .common import bytes2int as _bytes2int
from .common import crc16 as _crc16
from .common import int2bytes as _int2bytes
from .hidpp20_constants import (BATTERY_STATUS, CHARGE_LEVEL, CHARGE_STATUS, CHARGE_TYPE, DEVICE_KIND, ERROR, FEATURE,
FIRMWARE_KIND, GESTURE)
from .hidpp20_constants import BATTERY_STATUS, CHARGE_LEVEL, CHARGE_STATUS, CHARGE_TYPE, DEVICE_KIND, ERROR, FEATURE
from .hidpp20_constants import FIRMWARE_KIND as _FIRMWARE_KIND
from .hidpp20_constants import GESTURE
from .i18n import _

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -276,7 +277,7 @@ def _getCidReporting(self):
self._mapping_flags = mapping_flags_1 | (mapping_flags_2 << 8)
else:
raise exceptions.FeatureCallError(msg='No reply from device.')
except exceptions.FeatureCallError: # if the key hasn't ever been configured then the read may fail so only produce a warning
except exceptions.FeatureCallError: # if the key hasn't ever been configured only produce a warning
if logger.isEnabledFor(logging.WARNING):
logger.warn(
f'Feature Call Error in _getCidReporting on device {self._device} for cid {self._cid} - use defaults'
Expand Down Expand Up @@ -1381,11 +1382,11 @@ def get_firmware(device):
if build:
version += '.B%04X' % build
extras = fw_info[9:].rstrip(b'\x00') or None
fw_info = _FirmwareInfo(FIRMWARE_KIND[level], name.decode('ascii'), version, extras)
elif level == FIRMWARE_KIND.Hardware:
fw_info = _FirmwareInfo(FIRMWARE_KIND.Hardware, '', str(ord(fw_info[1:2])), None)
fw_info = _FirmwareInfo(_FIRMWARE_KIND[level], name.decode('ascii'), version, extras)
elif level == _FIRMWARE_KIND.Hardware:
fw_info = _FirmwareInfo(_FIRMWARE_KIND.Hardware, '', str(ord(fw_info[1:2])), None)
else:
fw_info = _FirmwareInfo(FIRMWARE_KIND.Other, '', '', None)
fw_info = _FirmwareInfo(_FIRMWARE_KIND.Other, '', '', None)

fw.append(fw_info)
# if logger.isEnabledFor(logging.DEBUG):
Expand Down
3 changes: 2 additions & 1 deletion lib/solaar/cli/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ def _print_device(dev, num=None):
if ids:
unitId, modelId, tid_map = ids
print(' Unit ID: %s Model ID: %s Transport IDs: %s' % (unitId, modelId, tid_map))
elif feature == _hidpp20_constants.FEATURE.REPORT_RATE or feature == _hidpp20_constants.FEATURE.EXTENDED_ADJUSTABLE_REPORT_RATE:
elif feature == _hidpp20_constants.FEATURE.REPORT_RATE or \
feature == _hidpp20_constants.FEATURE.EXTENDED_ADJUSTABLE_REPORT_RATE:
print(' Report Rate: %s' % _hidpp20.get_polling_rate(dev))
elif feature == _hidpp20_constants.FEATURE.REMAINING_PAIRING:
print(' Remaining Pairings: %d' % _hidpp20.get_remaining_pairing(dev))
Expand Down

0 comments on commit 476f41f

Please sign in to comment.