Skip to content

Commit

Permalink
update: Replace legacy logger.warn with logger.warning
Browse files Browse the repository at this point in the history
Related #1097
  • Loading branch information
MattHag committed Feb 29, 2024
1 parent 8056207 commit dda85be
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions lib/logitech_receiver/hidpp20.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _check(self) -> bool:
if fs_index:
count = self.device.request(fs_index << 8)
if count is None:
logger.warn("FEATURE_SET found, but failed to read features count")
logger.warning("FEATURE_SET found, but failed to read features count")
return False
else:
self.count = count[0] + 1 # ROOT feature not included in count
Expand Down Expand Up @@ -259,7 +259,7 @@ def _getCidReporting(self):
if mapped_data:
cid, mapping_flags_1, mapped_to = _unpack("!HBH", mapped_data[:5])
if cid != self._cid and logger.isEnabledFor(logging.WARNING):
logger.warn(
logger.warning(
f"REPROG_CONTROLS_V4 endpoint getCidReporting on device {self._device} replied "
+ f"with a different control ID ({cid}) than requested ({self._cid})."
)
Expand All @@ -273,7 +273,7 @@ def _getCidReporting(self):
raise exceptions.FeatureCallError(msg="No reply from device.")
except exceptions.FeatureCallError: # if the key hasn't ever been configured only produce a warning
if logger.isEnabledFor(logging.WARNING):
logger.warn(
logger.warning(
f"Feature Call Error in _getCidReporting on device {self._device} for cid {self._cid} - use defaults"
)
# Clear flags and set mapping target to self
Expand Down Expand Up @@ -437,7 +437,7 @@ def _query_key(self, index: int):
if group != 0: # 0 = does not belong to a group
self.group_cids[special_keys.CID_GROUP[group]].append(cid)
elif logger.isEnabledFor(logging.WARNING):
logger.warn(f"Key with index {index} was expected to exist but device doesn't report it.")
logger.warning(f"Key with index {index} was expected to exist but device doesn't report it.")

def _ensure_all_keys_queried(self):
"""The retrieval of key information is lazy, but for certain functionality
Expand Down Expand Up @@ -499,7 +499,7 @@ def _query_key(self, index: int):
self.keys[index] = ReprogrammableKey(self.device, index, cid, tid, flags)
self.cid_to_tid[cid] = tid
elif logger.isEnabledFor(logging.WARNING):
logger.warn(f"Key with index {index} was expected to exist but device doesn't report it.")
logger.warning(f"Key with index {index} was expected to exist but device doesn't report it.")


class KeysArrayV4(KeysArrayV1):
Expand All @@ -518,7 +518,7 @@ def _query_key(self, index: int):
if group != 0: # 0 = does not belong to a group
self.group_cids[special_keys.CID_GROUP[group]].append(cid)
elif logger.isEnabledFor(logging.WARNING):
logger.warn(f"Key with index {index} was expected to exist but device doesn't report it.")
logger.warning(f"Key with index {index} was expected to exist but device doesn't report it.")


# we are only interested in the current host, so use 0xFF for the host throughout
Expand Down Expand Up @@ -562,7 +562,7 @@ def _query_key(self, index: int):
remapped = modifiers = 0
self.keys[index] = PersistentRemappableAction(self.device, index, key, actionId, remapped, modifiers, status)
elif logger.isEnabledFor(logging.WARNING):
logger.warn(f"Key with index {index} was expected to exist but device doesn't report it.")
logger.warning(f"Key with index {index} was expected to exist but device doesn't report it.")


# Param Ids for feature GESTURE_2
Expand Down Expand Up @@ -786,7 +786,9 @@ def read(self):
value = feature_request(self._device, FEATURE.GESTURE_2, 0x50, self.id, 0xFF)
except exceptions.FeatureCallError: # some calls produce an error (notably spec 5 multiplier on K400Plus)
if logger.isEnabledFor(logging.WARNING):
logger.warn(f"Feature Call Error reading Gesture Spec on device {self._device} for spec {self.id} - use None")
logger.warning(
f"Feature Call Error reading Gesture Spec on device {self._device} for spec {self.id} - use None"
)
return None
return _bytes2int(value[: self.byte_count])

Expand Down Expand Up @@ -833,7 +835,7 @@ def __init__(self, device):
spec = Spec(device, field_low, field_high)
self.specs[spec.spec] = spec
else:
logger.warn(f"Unimplemented GESTURE_2 field {field_low} {field_high} found.")
logger.warning(f"Unimplemented GESTURE_2 field {field_low} {field_high} found.")
index += 1

def gesture(self, gesture):
Expand Down Expand Up @@ -1322,15 +1324,15 @@ def write(self, device):
try:
written = 1 if OnboardProfiles.write_sector(device, 0, self.to_bytes()) else 0
except Exception as e:
logger.warn("Exception writing onboard profile control sector")
logger.warning("Exception writing onboard profile control sector")
raise e
for p in self.profiles.values():
try:
if p.sector >= self.sectors:
raise Exception(f"Sector {p.sector} not a writable sector")
written += 1 if OnboardProfiles.write_sector(device, p.sector, p.to_bytes(self.size)) else 0
except Exception as e:
logger.warn(f"Exception writing onboard profile sector {p.sector}")
logger.warning(f"Exception writing onboard profile sector {p.sector}")
raise e
return written

Expand Down

0 comments on commit dda85be

Please sign in to comment.