pre-commit: initial fix
Signed-off-by: Filipe Laíns <lains@archlinux.org>
This commit is contained in:
parent
63fa581d13
commit
33521558ed
|
@ -111,4 +111,3 @@ Unifying Receiver
|
|||
23: unknown:0034 , default: Do Nothing One => unknown:0034
|
||||
nonstandard, pos:0, group:0, gmask:0
|
||||
Battery: 0%, full.
|
||||
|
||||
|
|
|
@ -40,4 +40,3 @@ Unifying Receiver
|
|||
6: SLEEP => Sleep nonstandard, reprogrammable
|
||||
7: Calculator => Calculator nonstandard, reprogrammable
|
||||
Battery: 90%, discharging.
|
||||
|
||||
|
|
|
@ -46,4 +46,3 @@ Device path : /dev/hidraw3
|
|||
2: MIDDLE BUTTON , default: MiddleMouseButton => MIDDLE BUTTON
|
||||
divertable, mse, reprogrammable, pos:0, group:2, gmask:3
|
||||
Battery status unavailable.
|
||||
|
||||
|
|
|
@ -48,4 +48,3 @@ Unifying Receiver
|
|||
2: MIDDLE BUTTON , default: MiddleMouseButton => MIDDLE BUTTON
|
||||
divertable, mse, reprogrammable, pos:0, group:2, gmask:3
|
||||
Battery: 5%, discharging.
|
||||
|
||||
|
|
|
@ -22,4 +22,3 @@ Unifying Receiver
|
|||
The power switch is located on the base.
|
||||
Notifications: battery status (0x100000).
|
||||
Battery: 100%, discharging.
|
||||
|
||||
|
|
|
@ -80,4 +80,3 @@ Unifying Receiver
|
|||
7: unknown:00D7 , default: unknown:00B4 => unknown:00D7
|
||||
divertable, virtual, pos:0, group:3, gmask:0
|
||||
Battery: 50%, discharging.
|
||||
|
||||
|
|
|
@ -79,4 +79,3 @@ Unifying Receiver
|
|||
1: RIGHT CLICK => RightClick mse, reprogrammable
|
||||
2: MIDDLE BUTTON => MiddleMouseButton mse, reprogrammable
|
||||
Battery: 30%, discharging.
|
||||
|
||||
|
|
|
@ -75,4 +75,3 @@ Unifying Receiver
|
|||
10: Volume Down => Volume Down is FN
|
||||
11: Volume Up => Volume Up is FN
|
||||
Battery: 90%, discharging.
|
||||
|
||||
|
|
|
@ -83,4 +83,3 @@ Unifying Receiver
|
|||
1: RIGHT CLICK => RightClick mse, reprogrammable
|
||||
2: MIDDLE BUTTON => MiddleMouseButton mse, reprogrammable
|
||||
Battery: 70%, discharging.
|
||||
|
||||
|
|
|
@ -58,4 +58,3 @@ Unifying Receiver
|
|||
The power switch is located on the top case.
|
||||
Notifications: (none).
|
||||
Battery: full, discharging.
|
||||
|
||||
|
|
|
@ -80,4 +80,3 @@ Unifying Receiver
|
|||
7: unknown:00D7 , default: unknown:00B4 => unknown:00D7
|
||||
divertable, virtual, pos:0, group:4, gmask:0
|
||||
Battery: 100%, discharging.
|
||||
|
||||
|
|
|
@ -275,4 +275,3 @@ Index (same as command)
|
|||
zz
|
||||
|
||||
(don't care, recommended to return 0)
|
||||
|
||||
|
|
|
@ -113,4 +113,3 @@ Solaar also has a command line interface that can do most of what can be
|
|||
done using the Solaar main window. For more information on the Solaar
|
||||
command line interface, run `solaar --help` to see the Solaar commands and
|
||||
then `solaar <command> --help` to see the arguments to any of the commands.
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ def _continuous_read(handle, timeout=2000):
|
|||
try:
|
||||
reply = _hid.read(handle, 128, timeout)
|
||||
except OSError as e:
|
||||
_error("Read failed, aborting: " + str(e), True)
|
||||
_error('Read failed, aborting: ' + str(e), True)
|
||||
break
|
||||
assert reply is not None
|
||||
if reply:
|
||||
|
@ -119,25 +119,25 @@ def _validate_input(line, hidpp=False):
|
|||
try:
|
||||
data = unhexlify(line.encode('ascii'))
|
||||
except Exception as e:
|
||||
_error("Invalid input: " + str(e))
|
||||
_error('Invalid input: ' + str(e))
|
||||
return None
|
||||
|
||||
if hidpp:
|
||||
if len(data) < 4:
|
||||
_error("Invalid HID++ request: need at least 4 bytes")
|
||||
_error('Invalid HID++ request: need at least 4 bytes')
|
||||
return None
|
||||
if data[:1] not in b'\x10\x11':
|
||||
_error("Invalid HID++ request: first byte must be 0x10 or 0x11")
|
||||
_error('Invalid HID++ request: first byte must be 0x10 or 0x11')
|
||||
return None
|
||||
if data[1:2] not in b'\xFF\x01\x02\x03\x04\x05\x06':
|
||||
_error(
|
||||
"Invalid HID++ request: second byte must be 0xFF or one of 0x01..0x06"
|
||||
'Invalid HID++ request: second byte must be 0xFF or one of 0x01..0x06'
|
||||
)
|
||||
return None
|
||||
if data[:1] == b'\x10':
|
||||
if len(data) > 7:
|
||||
_error(
|
||||
"Invalid HID++ request: maximum length of a 0x10 request is 7 bytes"
|
||||
'Invalid HID++ request: maximum length of a 0x10 request is 7 bytes'
|
||||
)
|
||||
return None
|
||||
while len(data) < 7:
|
||||
|
@ -145,7 +145,7 @@ def _validate_input(line, hidpp=False):
|
|||
elif data[:1] == b'\x11':
|
||||
if len(data) > 20:
|
||||
_error(
|
||||
"Invalid HID++ request: maximum length of a 0x11 request is 20 bytes"
|
||||
'Invalid HID++ request: maximum length of a 0x11 request is 20 bytes'
|
||||
)
|
||||
return None
|
||||
while len(data) < 20:
|
||||
|
@ -162,27 +162,27 @@ def _open(args):
|
|||
device = d.path
|
||||
break
|
||||
if not device:
|
||||
sys.exit("!! No HID++ receiver found.")
|
||||
sys.exit('!! No HID++ receiver found.')
|
||||
if not device:
|
||||
sys.exit("!! Device path required.")
|
||||
sys.exit('!! Device path required.')
|
||||
|
||||
print(".. Opening device", device)
|
||||
print('.. Opening device', device)
|
||||
handle = _hid.open_path(device)
|
||||
if not handle:
|
||||
sys.exit("!! Failed to open %s, aborting." % device)
|
||||
sys.exit('!! Failed to open %s, aborting.' % device)
|
||||
|
||||
print(".. Opened handle %r, vendor %r product %r serial %r." %
|
||||
print('.. Opened handle %r, vendor %r product %r serial %r.' %
|
||||
(handle, _hid.get_manufacturer(handle), _hid.get_product(handle),
|
||||
_hid.get_serial(handle)))
|
||||
if args.hidpp:
|
||||
if _hid.get_manufacturer(handle) != b'Logitech':
|
||||
sys.exit("!! Only Logitech devices support the HID++ protocol.")
|
||||
print(".. HID++ validation enabled.")
|
||||
sys.exit('!! Only Logitech devices support the HID++ protocol.')
|
||||
print('.. HID++ validation enabled.')
|
||||
else:
|
||||
if (_hid.get_manufacturer(handle) == b'Logitech'
|
||||
and b'Receiver' in _hid.get_product(handle)):
|
||||
args.hidpp = True
|
||||
print(".. Logitech receiver detected, HID++ validation enabled.")
|
||||
print('.. Logitech receiver detected, HID++ validation enabled.')
|
||||
|
||||
return handle
|
||||
|
||||
|
@ -196,15 +196,15 @@ def _parse_arguments():
|
|||
import argparse
|
||||
arg_parser = argparse.ArgumentParser()
|
||||
arg_parser.add_argument(
|
||||
'--history', help="history file (default ~/.hidconsole-history)")
|
||||
'--history', help='history file (default ~/.hidconsole-history)')
|
||||
arg_parser.add_argument('--hidpp',
|
||||
action='store_true',
|
||||
help="ensure input data is a valid HID++ request")
|
||||
help='ensure input data is a valid HID++ request')
|
||||
arg_parser.add_argument(
|
||||
'device',
|
||||
nargs='?',
|
||||
help="linux device to connect to (/dev/hidrawX); "
|
||||
"may be omitted if --hidpp is given, in which case it looks for the first Logitech receiver"
|
||||
help='linux device to connect to (/dev/hidrawX); '
|
||||
'may be omitted if --hidpp is given, in which case it looks for the first Logitech receiver'
|
||||
)
|
||||
return arg_parser.parse_args()
|
||||
|
||||
|
@ -215,7 +215,7 @@ def main():
|
|||
|
||||
if interactive:
|
||||
print(
|
||||
".. Press ^C/^D to exit, or type hex bytes to write to the device."
|
||||
'.. Press ^C/^D to exit, or type hex bytes to write to the device.'
|
||||
)
|
||||
|
||||
import readline
|
||||
|
@ -264,12 +264,12 @@ def main():
|
|||
time.sleep(0.700)
|
||||
except EOFError:
|
||||
if interactive:
|
||||
print("")
|
||||
print('')
|
||||
else:
|
||||
time.sleep(1)
|
||||
|
||||
finally:
|
||||
print(".. Closing handle %r" % handle)
|
||||
print('.. Closing handle %r' % handle)
|
||||
_hid.close(handle)
|
||||
if interactive:
|
||||
readline.write_history_file(args.history)
|
||||
|
|
|
@ -176,13 +176,13 @@ def write(handle, devnumber, data):
|
|||
else:
|
||||
wdata = _pack('!BB5s', 0x10, devnumber, data)
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("(%s) <= w[%02X %02X %s %s]", handle, ord(wdata[:1]),
|
||||
_log.debug('(%s) <= w[%02X %02X %s %s]', handle, ord(wdata[:1]),
|
||||
devnumber, _strhex(wdata[2:4]), _strhex(wdata[4:]))
|
||||
|
||||
try:
|
||||
_hid.write(int(handle), wdata)
|
||||
except Exception as reason:
|
||||
_log.error("write failed, assuming handle %r no longer available",
|
||||
_log.error('write failed, assuming handle %r no longer available',
|
||||
handle)
|
||||
close(handle)
|
||||
raise NoReceiver(reason=reason)
|
||||
|
@ -214,7 +214,7 @@ def check_message(data):
|
|||
if report_lengths.get(report_id) == len(data):
|
||||
return True
|
||||
else:
|
||||
_log.warn("unexpected message size: report_id %02X message %s" %
|
||||
_log.warn('unexpected message size: report_id %02X message %s' %
|
||||
(report_id, _strhex(data)))
|
||||
return False
|
||||
|
||||
|
@ -233,7 +233,7 @@ def _read(handle, timeout):
|
|||
timeout = int(timeout * 1000)
|
||||
data = _hid.read(int(handle), _MAX_READ_SIZE, timeout)
|
||||
except Exception as reason:
|
||||
_log.error("read failed, assuming handle %r no longer available",
|
||||
_log.error('read failed, assuming handle %r no longer available',
|
||||
handle)
|
||||
close(handle)
|
||||
raise NoReceiver(reason=reason)
|
||||
|
@ -243,7 +243,7 @@ def _read(handle, timeout):
|
|||
devnumber = ord(data[1:2])
|
||||
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("(%s) => r[%02X %02X %s %s]", handle, report_id,
|
||||
_log.debug('(%s) => r[%02X %02X %s %s]', handle, report_id,
|
||||
devnumber, _strhex(data[2:4]), _strhex(data[4:]))
|
||||
|
||||
return report_id, devnumber, data[2:]
|
||||
|
@ -265,7 +265,7 @@ def _skip_incoming(handle, ihandle, notifications_hook):
|
|||
# read whatever is already in the buffer, if any
|
||||
data = _hid.read(ihandle, _MAX_READ_SIZE, 0)
|
||||
except Exception as reason:
|
||||
_log.error("read failed, assuming receiver %s no longer available",
|
||||
_log.error('read failed, assuming receiver %s no longer available',
|
||||
handle)
|
||||
close(handle)
|
||||
raise NoReceiver(reason=reason)
|
||||
|
@ -389,7 +389,7 @@ def request(handle, devnumber, request_id, *params):
|
|||
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug(
|
||||
"(%s) device 0x%02X error on request {%04X}: %d = %s",
|
||||
'(%s) device 0x%02X error on request {%04X}: %d = %s',
|
||||
handle, devnumber, request_id, error,
|
||||
_hidpp10.ERROR[error])
|
||||
return
|
||||
|
@ -399,7 +399,7 @@ def request(handle, devnumber, request_id, *params):
|
|||
# a HID++ 2.0 feature call returned with an error
|
||||
error = ord(reply_data[3:4])
|
||||
_log.error(
|
||||
"(%s) device %d error on feature request {%04X}: %d = %s",
|
||||
'(%s) device %d error on feature request {%04X}: %d = %s',
|
||||
handle, devnumber, request_id, error,
|
||||
_hidpp20.ERROR[error])
|
||||
raise _hidpp20.FeatureCallError(number=devnumber,
|
||||
|
@ -445,7 +445,7 @@ def request(handle, devnumber, request_id, *params):
|
|||
# if _log.isEnabledFor(_DEBUG):
|
||||
# _log.debug("(%s) still waiting for reply, delta %f", handle, delta)
|
||||
|
||||
_log.warn("timeout (%0.2f/%0.2f) on device %d request {%04X} params [%s]",
|
||||
_log.warn('timeout (%0.2f/%0.2f) on device %d request {%04X} params [%s]',
|
||||
delta, timeout, devnumber, request_id, _strhex(params))
|
||||
# raise DeviceUnreachable(number=devnumber, request=request_id)
|
||||
|
||||
|
@ -456,7 +456,7 @@ def ping(handle, devnumber):
|
|||
:returns: The HID protocol supported by the device, as a floating point number, if the device is active.
|
||||
"""
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("(%s) pinging device %d", handle, devnumber)
|
||||
_log.debug('(%s) pinging device %d', handle, devnumber)
|
||||
|
||||
# import inspect as _inspect
|
||||
# print ('\n '.join(str(s) for s in _inspect.stack()))
|
||||
|
@ -504,7 +504,7 @@ def ping(handle, devnumber):
|
|||
|
||||
if error == _hidpp10.ERROR.unknown_device: # no paired device with that number
|
||||
_log.error(
|
||||
"(%s) device %d error on ping request: unknown device",
|
||||
'(%s) device %d error on ping request: unknown device',
|
||||
handle, devnumber)
|
||||
raise NoSuchDevice(number=devnumber,
|
||||
request=request_id)
|
||||
|
@ -518,6 +518,6 @@ def ping(handle, devnumber):
|
|||
|
||||
delta = _timestamp() - request_started
|
||||
|
||||
_log.warn("(%s) timeout (%0.2f/%0.2f) on device %d ping", handle, delta,
|
||||
_log.warn('(%s) timeout (%0.2f/%0.2f) on device %d ping', handle, delta,
|
||||
_PING_TIMEOUT, devnumber)
|
||||
# raise DeviceUnreachable(number=devnumber, request=request_id)
|
||||
|
|
|
@ -107,7 +107,7 @@ class NamedInts(object):
|
|||
def __init__(self, **kwargs):
|
||||
def _readable_name(n):
|
||||
if not is_string(n):
|
||||
raise TypeError("expected (unicode) string, got " +
|
||||
raise TypeError('expected (unicode) string, got ' +
|
||||
str(type(n)))
|
||||
return n.replace('__', '/').replace('_', ' ')
|
||||
|
||||
|
|
|
@ -202,7 +202,7 @@ def parse_battery_status(register, reply):
|
|||
elif charging_byte & 0x22 == 0x22:
|
||||
status_text = BATTERY_STATUS.full
|
||||
else:
|
||||
_log.warn("could not parse 0x07 battery status: %02X (level %02X)",
|
||||
_log.warn('could not parse 0x07 battery status: %02X (level %02X)',
|
||||
charging_byte, status_byte)
|
||||
status_text = None
|
||||
|
||||
|
|
|
@ -268,7 +268,7 @@ class FeaturesArray(object):
|
|||
count = self.device.request(fs_index << 8)
|
||||
if count is None:
|
||||
_log.warn(
|
||||
"FEATURE_SET found, but failed to read features count"
|
||||
'FEATURE_SET found, but failed to read features count'
|
||||
)
|
||||
# most likely the device is unavailable
|
||||
return False
|
||||
|
@ -348,7 +348,7 @@ class FeaturesArray(object):
|
|||
self.features[index] = FEATURE[ivalue]
|
||||
return index
|
||||
|
||||
raise ValueError("%r not in list" % featureId)
|
||||
raise ValueError('%r not in list' % featureId)
|
||||
|
||||
def __iter__(self):
|
||||
if self._check():
|
||||
|
@ -530,7 +530,7 @@ def get_name(device):
|
|||
name += fragment[:name_length - len(name)]
|
||||
else:
|
||||
_log.error(
|
||||
"failed to read whole name of %s (expected %d chars)",
|
||||
'failed to read whole name of %s (expected %d chars)',
|
||||
device, name_length)
|
||||
return None
|
||||
|
||||
|
@ -545,7 +545,7 @@ def get_battery(device):
|
|||
discharge = None if discharge == 0 else discharge
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug(
|
||||
"device %d battery %d%% charged, next level %d%% charge, status %d = %s",
|
||||
'device %d battery %d%% charged, next level %d%% charge, status %d = %s',
|
||||
device.number, discharge, dischargeNext, status,
|
||||
BATTERY_STATUS[status])
|
||||
return discharge, BATTERY_STATUS[status], dischargeNext
|
||||
|
@ -583,7 +583,7 @@ def decipher_voltage(voltage_report):
|
|||
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug(
|
||||
"device %d, battery voltage %d mV, charging = %s, charge status %d = %s, charge level %s, charge type %s",
|
||||
'device %d, battery voltage %d mV, charging = %s, charge status %d = %s, charge level %s, charge type %s',
|
||||
device.number, voltage, status, (flags & 0x03), charge_sts,
|
||||
charge_lvl, charge_type)
|
||||
|
||||
|
|
|
@ -35,30 +35,30 @@ except:
|
|||
|
||||
_DUMMY = (
|
||||
# approximative battery levels
|
||||
_("empty"),
|
||||
_("critical"),
|
||||
_("low"),
|
||||
_("good"),
|
||||
_("full"),
|
||||
_('empty'),
|
||||
_('critical'),
|
||||
_('low'),
|
||||
_('good'),
|
||||
_('full'),
|
||||
|
||||
# battery charging statuses
|
||||
_("discharging"),
|
||||
_("recharging"),
|
||||
_("almost full"),
|
||||
_("charged"),
|
||||
_("slow recharge"),
|
||||
_("invalid battery"),
|
||||
_("thermal error"),
|
||||
_('discharging'),
|
||||
_('recharging'),
|
||||
_('almost full'),
|
||||
_('charged'),
|
||||
_('slow recharge'),
|
||||
_('invalid battery'),
|
||||
_('thermal error'),
|
||||
|
||||
# pairing errors
|
||||
_("device timeout"),
|
||||
_("device not supported"),
|
||||
_("too many devices"),
|
||||
_("sequence timeout"),
|
||||
_('device timeout'),
|
||||
_('device not supported'),
|
||||
_('too many devices'),
|
||||
_('sequence timeout'),
|
||||
|
||||
# firmware kinds
|
||||
_("Firmware"),
|
||||
_("Bootloader"),
|
||||
_("Hardware"),
|
||||
_("Other"),
|
||||
_('Firmware'),
|
||||
_('Bootloader'),
|
||||
_('Hardware'),
|
||||
_('Other'),
|
||||
)
|
||||
|
|
|
@ -67,7 +67,7 @@ class _ThreadedHandle(object):
|
|||
def _open(self):
|
||||
handle = _base.open_path(self.path)
|
||||
if handle is None:
|
||||
_log.error("%r failed to open new handle", self)
|
||||
_log.error('%r failed to open new handle', self)
|
||||
else:
|
||||
# if _log.isEnabledFor(_DEBUG):
|
||||
# _log.debug("%r opened new handle %d", self, handle)
|
||||
|
@ -80,7 +80,7 @@ class _ThreadedHandle(object):
|
|||
self._local = None
|
||||
handles, self._handles = self._handles, []
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("%r closing %s", self, handles)
|
||||
_log.debug('%r closing %s', self, handles)
|
||||
for h in handles:
|
||||
_base.close(h)
|
||||
|
||||
|
@ -163,7 +163,7 @@ class EventsListener(_threading.Thread):
|
|||
# get the right low-level handle for this thread
|
||||
ihandle = int(self.receiver.handle)
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info("started with %s (%d)", self.receiver, ihandle)
|
||||
_log.info('started with %s (%d)', self.receiver, ihandle)
|
||||
|
||||
self.has_started()
|
||||
|
||||
|
@ -178,7 +178,7 @@ class EventsListener(_threading.Thread):
|
|||
# _log.debug("read next notification")
|
||||
n = _base.read(ihandle, _EVENT_READ_TIMEOUT)
|
||||
except _base.NoReceiver:
|
||||
_log.warning("receiver disconnected")
|
||||
_log.warning('receiver disconnected')
|
||||
self.receiver.close()
|
||||
break
|
||||
|
||||
|
@ -194,7 +194,7 @@ class EventsListener(_threading.Thread):
|
|||
try:
|
||||
self._notifications_callback(n)
|
||||
except:
|
||||
_log.exception("processing %s", n)
|
||||
_log.exception('processing %s', n)
|
||||
|
||||
# elif self.tick_period:
|
||||
# idle_reads -= 1
|
||||
|
|
|
@ -72,10 +72,10 @@ def _process_receiver_notification(receiver, status, n):
|
|||
# pairing lock notification
|
||||
if n.sub_id == 0x4A:
|
||||
status.lock_open = bool(n.address & 0x01)
|
||||
reason = (_("pairing lock is open")
|
||||
if status.lock_open else _("pairing lock is closed"))
|
||||
reason = (_('pairing lock is open')
|
||||
if status.lock_open else _('pairing lock is closed'))
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info("%s: %s", receiver, reason)
|
||||
_log.info('%s: %s', receiver, reason)
|
||||
|
||||
status[_K.ERROR] = None
|
||||
if status.lock_open:
|
||||
|
@ -86,12 +86,12 @@ def _process_receiver_notification(receiver, status, n):
|
|||
status[
|
||||
_K.ERROR] = error_string = _hidpp10.PAIRING_ERRORS[pair_error]
|
||||
status.new_device = None
|
||||
_log.warn("pairing error %d: %s", pair_error, error_string)
|
||||
_log.warn('pairing error %d: %s', pair_error, error_string)
|
||||
|
||||
status.changed(reason=reason)
|
||||
return True
|
||||
|
||||
_log.warn("%s: unhandled notification %s", receiver, n)
|
||||
_log.warn('%s: unhandled notification %s', receiver, n)
|
||||
|
||||
|
||||
#
|
||||
|
@ -124,7 +124,7 @@ def _process_device_notification(device, status, n):
|
|||
try:
|
||||
feature = device.features[n.sub_id]
|
||||
except IndexError:
|
||||
_log.warn("%s: notification from invalid feature index %02X: %s",
|
||||
_log.warn('%s: notification from invalid feature index %02X: %s',
|
||||
device, n.sub_id, n)
|
||||
return False
|
||||
|
||||
|
@ -133,31 +133,31 @@ def _process_device_notification(device, status, n):
|
|||
|
||||
def _process_dj_notification(device, status, n):
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("%s (%s) DJ notification %s", device, device.protocol, n)
|
||||
_log.debug('%s (%s) DJ notification %s', device, device.protocol, n)
|
||||
|
||||
if n.sub_id == 0x40:
|
||||
# do all DJ paired notifications also show up as HID++ 1.0 notifications?
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info("%s: ignoring DJ unpaired: %s", device, n)
|
||||
_log.info('%s: ignoring DJ unpaired: %s', device, n)
|
||||
return True
|
||||
|
||||
if n.sub_id == 0x41:
|
||||
# do all DJ paired notifications also show up as HID++ 1.0 notifications?
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info("%s: ignoring DJ paired: %s", device, n)
|
||||
_log.info('%s: ignoring DJ paired: %s', device, n)
|
||||
return True
|
||||
|
||||
if n.sub_id == 0x42:
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info("%s: ignoring DJ connection: %s", device, n)
|
||||
_log.info('%s: ignoring DJ connection: %s', device, n)
|
||||
return True
|
||||
|
||||
_log.warn("%s: unrecognized DJ %s", device, n)
|
||||
_log.warn('%s: unrecognized DJ %s', device, n)
|
||||
|
||||
|
||||
def _process_hidpp10_custom_notification(device, status, n):
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("%s (%s) custom notification %s", device, device.protocol,
|
||||
_log.debug('%s (%s) custom notification %s', device, device.protocol,
|
||||
n)
|
||||
|
||||
if n.sub_id in (_R.battery_status, _R.battery_charge):
|
||||
|
@ -172,10 +172,10 @@ def _process_hidpp10_custom_notification(device, status, n):
|
|||
# message layout: 10 ix 17("address") <??> <?> <??> <light level 1=off..5=max>
|
||||
# TODO anything we can do with this?
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info("illumination event: %s", n)
|
||||
_log.info('illumination event: %s', n)
|
||||
return True
|
||||
|
||||
_log.warn("%s: unrecognized %s", device, n)
|
||||
_log.warn('%s: unrecognized %s', device, n)
|
||||
|
||||
|
||||
def _process_hidpp10_notification(device, status, n):
|
||||
|
@ -190,9 +190,9 @@ def _process_hidpp10_notification(device, status, n):
|
|||
del device.receiver[device.number]
|
||||
status.changed(active=False,
|
||||
alert=_ALERT.ALL,
|
||||
reason=_("unpaired"))
|
||||
reason=_('unpaired'))
|
||||
else:
|
||||
_log.warn("%s: disconnection with unknown type %02X: %s", device,
|
||||
_log.warn('%s: disconnection with unknown type %02X: %s', device,
|
||||
n.address, n)
|
||||
return True
|
||||
|
||||
|
@ -211,7 +211,7 @@ def _process_hidpp10_notification(device, status, n):
|
|||
if protocol_name:
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
wpid = _strhex(n.data[2:3] + n.data[1:2])
|
||||
assert wpid == device.wpid, "%s wpid mismatch, got %s" % (
|
||||
assert wpid == device.wpid, '%s wpid mismatch, got %s' % (
|
||||
device, wpid)
|
||||
|
||||
flags = ord(n.data[:1]) & 0xF0
|
||||
|
@ -221,14 +221,14 @@ def _process_hidpp10_notification(device, status, n):
|
|||
sw_present = bool(flags & 0x10)
|
||||
has_payload = bool(flags & 0x80)
|
||||
_log.debug(
|
||||
"%s: %s connection notification: software=%s, encrypted=%s, link=%s, payload=%s",
|
||||
'%s: %s connection notification: software=%s, encrypted=%s, link=%s, payload=%s',
|
||||
device, protocol_name, sw_present, link_encrypted,
|
||||
link_established, has_payload)
|
||||
status[_K.LINK_ENCRYPTED] = link_encrypted
|
||||
status.changed(active=link_established)
|
||||
else:
|
||||
_log.warn(
|
||||
"%s: connection notification with unknown protocol %02X: %s",
|
||||
'%s: connection notification with unknown protocol %02X: %s',
|
||||
device.number, n.address, n)
|
||||
|
||||
return True
|
||||
|
@ -244,16 +244,16 @@ def _process_hidpp10_notification(device, status, n):
|
|||
if n.sub_id == 0x4B:
|
||||
if n.address == 0x01:
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("%s: device powered on", device)
|
||||
reason = status.to_string() or _("powered on")
|
||||
_log.debug('%s: device powered on', device)
|
||||
reason = status.to_string() or _('powered on')
|
||||
status.changed(active=True,
|
||||
alert=_ALERT.NOTIFICATION,
|
||||
reason=reason)
|
||||
else:
|
||||
_log.warn("%s: unknown %s", device, n)
|
||||
_log.warn('%s: unknown %s', device, n)
|
||||
return True
|
||||
|
||||
_log.warn("%s: unrecognized %s", device, n)
|
||||
_log.warn('%s: unrecognized %s', device, n)
|
||||
|
||||
|
||||
def _process_feature_notification(device, status, n, feature):
|
||||
|
@ -267,7 +267,7 @@ def _process_feature_notification(device, status, n, feature):
|
|||
_hidpp20.BATTERY_STATUS[battery_status],
|
||||
discharge_next_level)
|
||||
else:
|
||||
_log.warn("%s: unknown BATTERY %s", device, n)
|
||||
_log.warn('%s: unknown BATTERY %s', device, n)
|
||||
return True
|
||||
|
||||
if feature == _F.BATTERY_VOLTAGE:
|
||||
|
@ -276,30 +276,30 @@ def _process_feature_notification(device, status, n, feature):
|
|||
n.data)
|
||||
status.set_battery_info(level, status, None, voltage)
|
||||
else:
|
||||
_log.warn("%s: unknown VOLTAGE %s", device, n)
|
||||
_log.warn('%s: unknown VOLTAGE %s', device, n)
|
||||
return True
|
||||
|
||||
# TODO: what are REPROG_CONTROLS_V{2,3}?
|
||||
if feature == _F.REPROG_CONTROLS:
|
||||
if n.address == 0x00:
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info("%s: reprogrammable key: %s", device, n)
|
||||
_log.info('%s: reprogrammable key: %s', device, n)
|
||||
else:
|
||||
_log.warn("%s: unknown REPROGRAMMABLE KEYS %s", device, n)
|
||||
_log.warn('%s: unknown REPROGRAMMABLE KEYS %s', device, n)
|
||||
return True
|
||||
|
||||
if feature == _F.WIRELESS_DEVICE_STATUS:
|
||||
if n.address == 0x00:
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("wireless status: %s", n)
|
||||
_log.debug('wireless status: %s', n)
|
||||
if n.data[0:3] == b'\x01\x01\x01':
|
||||
status.changed(active=True,
|
||||
alert=_ALERT.NOTIFICATION,
|
||||
reason='powered on')
|
||||
else:
|
||||
_log.warn("%s: unknown WIRELESS %s", device, n)
|
||||
_log.warn('%s: unknown WIRELESS %s', device, n)
|
||||
else:
|
||||
_log.warn("%s: unknown WIRELESS %s", device, n)
|
||||
_log.warn('%s: unknown WIRELESS %s', device, n)
|
||||
return True
|
||||
|
||||
if feature == _F.SOLAR_DASHBOARD:
|
||||
|
@ -319,7 +319,7 @@ def _process_feature_notification(device, status, n, feature):
|
|||
status.set_battery_info(charge, status_text, None)
|
||||
elif n.address == 0x20:
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("%s: Light Check button pressed", device)
|
||||
_log.debug('%s: Light Check button pressed', device)
|
||||
status.changed(alert=_ALERT.SHOW_WINDOW)
|
||||
# first cancel any reporting
|
||||
# device.feature_request(_F.SOLAR_DASHBOARD)
|
||||
|
@ -329,25 +329,25 @@ def _process_feature_notification(device, status, n, feature):
|
|||
device.feature_request(_F.SOLAR_DASHBOARD, 0x00, reports_count,
|
||||
reports_period)
|
||||
else:
|
||||
_log.warn("%s: unknown SOLAR CHARGE %s", device, n)
|
||||
_log.warn('%s: unknown SOLAR CHARGE %s', device, n)
|
||||
else:
|
||||
_log.warn("%s: SOLAR CHARGE not GOOD? %s", device, n)
|
||||
_log.warn('%s: SOLAR CHARGE not GOOD? %s', device, n)
|
||||
return True
|
||||
|
||||
if feature == _F.TOUCHMOUSE_RAW_POINTS:
|
||||
if n.address == 0x00:
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info("%s: TOUCH MOUSE points %s", device, n)
|
||||
_log.info('%s: TOUCH MOUSE points %s', device, n)
|
||||
elif n.address == 0x10:
|
||||
touch = ord(n.data[:1])
|
||||
button_down = bool(touch & 0x02)
|
||||
mouse_lifted = bool(touch & 0x01)
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info(
|
||||
"%s: TOUCH MOUSE status: button_down=%s mouse_lifted=%s",
|
||||
'%s: TOUCH MOUSE status: button_down=%s mouse_lifted=%s',
|
||||
device, button_down, mouse_lifted)
|
||||
else:
|
||||
_log.warn("%s: unknown TOUCH MOUSE %s", device, n)
|
||||
_log.warn('%s: unknown TOUCH MOUSE %s', device, n)
|
||||
return True
|
||||
|
||||
if feature == _F.HIRES_WHEEL:
|
||||
|
@ -356,18 +356,18 @@ def _process_feature_notification(device, status, n, feature):
|
|||
flags, delta_v = _unpack('>bh', n.data[:3])
|
||||
high_res = (flags & 0x10) != 0
|
||||
periods = flags & 0x0f
|
||||
_log.info("%s: WHEEL: res: %d periods: %d delta V:%-3d",
|
||||
_log.info('%s: WHEEL: res: %d periods: %d delta V:%-3d',
|
||||
device, high_res, periods, delta_v)
|
||||
return True
|
||||
elif (n.address == 0x10):
|
||||
if _log.isEnabledFor(_INFO):
|
||||
flags = ord(n.data[:1])
|
||||
ratchet = flags & 0x01
|
||||
_log.info("%s: WHEEL: ratchet: %d", device, ratchet)
|
||||
_log.info('%s: WHEEL: ratchet: %d', device, ratchet)
|
||||
return True
|
||||
else:
|
||||
_log.warn("%s: unknown WHEEL %s", device, n)
|
||||
_log.warn('%s: unknown WHEEL %s', device, n)
|
||||
return True
|
||||
|
||||
_log.warn("%s: unrecognized %s for feature %s (index %02X)", device, n,
|
||||
_log.warn('%s: unrecognized %s for feature %s (index %02X)', device, n,
|
||||
feature, n.sub_id)
|
||||
|
|
|
@ -106,19 +106,19 @@ class PairedDevice(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",
|
||||
_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")
|
||||
error='read Nano wpid')
|
||||
|
||||
self.wpid = _strhex(device_info[3:5])
|
||||
self._polling_rate = 0
|
||||
self._power_switch = '(' + _("unknown") + ')'
|
||||
self._power_switch = '(' + _('unknown') + ')'
|
||||
|
||||
# the wpid is necessary to properly identify wireless link on/off notifications
|
||||
# also it gets set to None on this object when the device is unpaired
|
||||
assert self.wpid is not None, "failed to read wpid: device %d of %s" % (
|
||||
assert self.wpid is not None, 'failed to read wpid: device %d of %s' % (
|
||||
number, receiver)
|
||||
|
||||
self.descriptor = _DESCRIPTORS.get(self.wpid)
|
||||
|
@ -289,14 +289,14 @@ class PairedDevice(object):
|
|||
set_flag_bits = 0
|
||||
ok = _hidpp10.set_notification_flags(self, set_flag_bits)
|
||||
if ok is None:
|
||||
_log.warn("%s: failed to %s device notifications", self,
|
||||
_log.warn('%s: failed to %s device notifications', self,
|
||||
'enable' if enable else 'disable')
|
||||
|
||||
flag_bits = _hidpp10.get_notification_flags(self)
|
||||
flag_names = None if flag_bits is None else tuple(
|
||||
_hidpp10.NOTIFICATION_FLAG.flag_names(flag_bits))
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info("%s: device notifications %s %s", self,
|
||||
_log.info('%s: device notifications %s %s', self,
|
||||
'enabled' if enable else 'disabled', flag_names)
|
||||
return flag_bits if ok else None
|
||||
|
||||
|
@ -364,7 +364,7 @@ class Receiver(object):
|
|||
self.product_id = device_info.product_id
|
||||
product_info = _product_information(self.product_id)
|
||||
if not product_info:
|
||||
raise Exception("Unknown receiver type", self.product_id)
|
||||
raise Exception('Unknown receiver type', self.product_id)
|
||||
|
||||
# read the serial immediately, so we can find out max_devices
|
||||
serial_reply = self.read_register(_R.receiver_info, 0x03)
|
||||
|
@ -426,7 +426,7 @@ class Receiver(object):
|
|||
set_flag_bits = 0
|
||||
ok = _hidpp10.set_notification_flags(self, set_flag_bits)
|
||||
if ok is None:
|
||||
_log.warn("%s: failed to %s receiver notifications", self,
|
||||
_log.warn('%s: failed to %s receiver notifications', self,
|
||||
'enable' if enable else 'disable')
|
||||
return None
|
||||
|
||||
|
@ -434,7 +434,7 @@ class Receiver(object):
|
|||
flag_names = None if flag_bits is None else tuple(
|
||||
_hidpp10.NOTIFICATION_FLAG.flag_names(flag_bits))
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info("%s: receiver notifications %s => %s", self,
|
||||
_log.info('%s: receiver notifications %s => %s', self,
|
||||
'enabled' if enable else 'disabled', flag_names)
|
||||
return flag_bits
|
||||
|
||||
|
@ -442,12 +442,12 @@ class Receiver(object):
|
|||
"""Scan all devices."""
|
||||
if self.handle:
|
||||
if not self.write_register(_R.receiver_connection, 0x02):
|
||||
_log.warn("%s: failed to trigger device link notifications",
|
||||
_log.warn('%s: failed to trigger device link notifications',
|
||||
self)
|
||||
|
||||
def register_new_device(self, number, notification=None):
|
||||
if self._devices.get(number) is not None:
|
||||
raise IndexError("%s: device number %d already registered" %
|
||||
raise IndexError('%s: device number %d already registered' %
|
||||
(self, number))
|
||||
|
||||
assert notification is None or notification.devnumber == number
|
||||
|
@ -457,14 +457,14 @@ class Receiver(object):
|
|||
dev = PairedDevice(self, number, notification)
|
||||
assert dev.wpid
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info("%s: found new device %d (%s)", self, number,
|
||||
_log.info('%s: found new device %d (%s)', self, number,
|
||||
dev.wpid)
|
||||
self._devices[number] = dev
|
||||
return dev
|
||||
except _base.NoSuchDevice:
|
||||
_log.exception("register_new_device")
|
||||
_log.exception('register_new_device')
|
||||
|
||||
_log.warning("%s: looked for device %d, not found", self, number)
|
||||
_log.warning('%s: looked for device %d, not found', self, number)
|
||||
self._devices[number] = None
|
||||
|
||||
def set_lock(self, lock_closed=True, device=0, timeout=0):
|
||||
|
@ -474,7 +474,7 @@ class Receiver(object):
|
|||
timeout)
|
||||
if reply:
|
||||
return True
|
||||
_log.warn("%s: failed to %s the receiver lock", self,
|
||||
_log.warn('%s: failed to %s the receiver lock', self,
|
||||
'close' if lock_closed else 'open')
|
||||
|
||||
def count(self):
|
||||
|
@ -536,7 +536,7 @@ class Receiver(object):
|
|||
dev.wpid = None
|
||||
if key in self._devices:
|
||||
del self._devices[key]
|
||||
_log.warn("%s removed device %s", self, dev)
|
||||
_log.warn('%s removed device %s', self, dev)
|
||||
else:
|
||||
reply = self.write_register(_R.receiver_pairing, 0x03, key)
|
||||
if reply:
|
||||
|
@ -545,9 +545,9 @@ class Receiver(object):
|
|||
dev.wpid = None
|
||||
if key in self._devices:
|
||||
del self._devices[key]
|
||||
_log.warn("%s unpaired device %s", self, dev)
|
||||
_log.warn('%s unpaired device %s', self, dev)
|
||||
else:
|
||||
_log.error("%s failed to unpair device %s", self, dev)
|
||||
_log.error('%s failed to unpair device %s', self, dev)
|
||||
raise IndexError(key)
|
||||
|
||||
def __len__(self):
|
||||
|
@ -586,8 +586,8 @@ class Receiver(object):
|
|||
if handle:
|
||||
return Receiver(handle, device_info)
|
||||
except OSError as e:
|
||||
_log.exception("open %s", device_info)
|
||||
_log.exception('open %s', device_info)
|
||||
if e.errno == _errno.EACCES:
|
||||
raise
|
||||
except:
|
||||
_log.exception("open %s", device_info)
|
||||
_log.exception('open %s', device_info)
|
||||
|
|
|
@ -110,7 +110,7 @@ class Setting(object):
|
|||
assert hasattr(self, '_device')
|
||||
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("%s: settings read %r from %s", self.name, self._value,
|
||||
_log.debug('%s: settings read %r from %s', self.name, self._value,
|
||||
self._device)
|
||||
|
||||
if self._value is None and self._device.persister:
|
||||
|
@ -141,7 +141,7 @@ class Setting(object):
|
|||
assert value is not None
|
||||
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("%s: settings write %r to %s", self.name, value,
|
||||
_log.debug('%s: settings write %r to %s', self.name, value,
|
||||
self._device)
|
||||
|
||||
if self._device.online:
|
||||
|
@ -160,7 +160,7 @@ class Setting(object):
|
|||
data_bytes = self._validator.prepare_write(value, current_value)
|
||||
if data_bytes is not None:
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("%s: settings prepare write(%s) => %r",
|
||||
_log.debug('%s: settings prepare write(%s) => %r',
|
||||
self.name, value, data_bytes)
|
||||
|
||||
reply = self._rw.write(self._device, data_bytes)
|
||||
|
@ -175,7 +175,7 @@ class Setting(object):
|
|||
assert hasattr(self, '_device')
|
||||
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("%s: apply %s (%s)", self.name, self._value,
|
||||
_log.debug('%s: apply %s (%s)', self.name, self._value,
|
||||
self._device)
|
||||
|
||||
value = self.read()
|
||||
|
@ -202,7 +202,7 @@ class Settings(Setting):
|
|||
assert hasattr(self, '_device')
|
||||
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("%s: settings read %r from %s", self.name, self._value,
|
||||
_log.debug('%s: settings read %r from %s', self.name, self._value,
|
||||
self._device)
|
||||
|
||||
if self._value is None and getattr(self._device, 'persister', None):
|
||||
|
@ -219,7 +219,7 @@ class Settings(Setting):
|
|||
return self._value
|
||||
|
||||
if self._device.online:
|
||||
reply_map = dict()
|
||||
reply_map = {}
|
||||
for key, value in self._validator.choices.items():
|
||||
reply = self._rw.read(self._device, key)
|
||||
if reply:
|
||||
|
@ -241,7 +241,7 @@ class Settings(Setting):
|
|||
assert key is not None
|
||||
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("%s: settings read %r key %r from %s", self.name,
|
||||
_log.debug('%s: settings read %r key %r from %s', self.name,
|
||||
self._value, key, self._device)
|
||||
|
||||
if self._value is None and getattr(self._device, 'persister', None):
|
||||
|
@ -269,7 +269,7 @@ class Settings(Setting):
|
|||
assert map is not None
|
||||
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("%s: settings write %r to %s", self.name, map,
|
||||
_log.debug('%s: settings write %r to %s', self.name, map,
|
||||
self._device)
|
||||
|
||||
if self._device.online:
|
||||
|
@ -285,7 +285,7 @@ class Settings(Setting):
|
|||
if data_bytes is not None:
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug(
|
||||
"%s: settings prepare map write(%s,%s) => %r",
|
||||
'%s: settings prepare map write(%s,%s) => %r',
|
||||
self.name, key, value, data_bytes)
|
||||
reply = self._rw.write(self._device, int(key), data_bytes)
|
||||
if not reply:
|
||||
|
@ -300,7 +300,7 @@ class Settings(Setting):
|
|||
assert value is not None
|
||||
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("%s: settings write key %r value %r to %s", self.name,
|
||||
_log.debug('%s: settings write key %r value %r to %s', self.name,
|
||||
key, value, self._device)
|
||||
|
||||
if self._device.online:
|
||||
|
@ -315,7 +315,7 @@ class Settings(Setting):
|
|||
if data_bytes is not None:
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug(
|
||||
"%s: settings prepare key value write(%s,%s) => %r",
|
||||
'%s: settings prepare key value write(%s,%s) => %r',
|
||||
self.name, key, value, data_bytes)
|
||||
reply = self._rw.write(self._device, int(key), data_bytes)
|
||||
if not reply:
|
||||
|
@ -333,7 +333,7 @@ class BitFieldSetting(Setting):
|
|||
assert hasattr(self, '_device')
|
||||
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("%s: settings read %r from %s", self.name, self._value,
|
||||
_log.debug('%s: settings read %r from %s', self.name, self._value,
|
||||
self._device)
|
||||
|
||||
if self._value is None and getattr(self._device, 'persister', None):
|
||||
|
@ -350,7 +350,7 @@ class BitFieldSetting(Setting):
|
|||
return self._value
|
||||
|
||||
if self._device.online:
|
||||
reply_map = dict()
|
||||
reply_map = {}
|
||||
reply = self._rw.read(self._device)
|
||||
if reply:
|
||||
# keys are ints, because that is what the device uses,
|
||||
|
@ -370,7 +370,7 @@ class BitFieldSetting(Setting):
|
|||
assert key is not None
|
||||
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("%s: settings read %r key %r from %s", self.name,
|
||||
_log.debug('%s: settings read %r key %r from %s', self.name,
|
||||
self._value, key, self._device)
|
||||
|
||||
if self._value is None and getattr(self._device, 'persister', None):
|
||||
|
@ -397,7 +397,7 @@ class BitFieldSetting(Setting):
|
|||
assert map is not None
|
||||
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("%s: settings write %r to %s", self.name, map,
|
||||
_log.debug('%s: settings write %r to %s', self.name, map,
|
||||
self._device)
|
||||
|
||||
if self._device.online:
|
||||
|
@ -410,7 +410,7 @@ class BitFieldSetting(Setting):
|
|||
data_bytes = self._validator.prepare_write(self._value)
|
||||
if data_bytes is not None:
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("%s: settings prepare map write(%s) => %r",
|
||||
_log.debug('%s: settings prepare map write(%s) => %r',
|
||||
self.name, self._value, data_bytes)
|
||||
reply = self._rw.write(self._device, data_bytes)
|
||||
if not reply:
|
||||
|
@ -424,7 +424,7 @@ class BitFieldSetting(Setting):
|
|||
assert value is not None
|
||||
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("%s: settings write key %r value %r to %s", self.name,
|
||||
_log.debug('%s: settings write key %r value %r to %s', self.name,
|
||||
key, value, self._device)
|
||||
|
||||
if self._device.online:
|
||||
|
@ -440,7 +440,7 @@ class BitFieldSetting(Setting):
|
|||
if data_bytes is not None:
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug(
|
||||
"%s: settings prepare key value write(%s,%s) => %r",
|
||||
'%s: settings prepare key value write(%s,%s) => %r',
|
||||
self.name, key, str(value), data_bytes)
|
||||
reply = self._rw.write(self._device, data_bytes)
|
||||
if not reply:
|
||||
|
@ -583,13 +583,13 @@ class BooleanValidator(object):
|
|||
if isinstance(self.mask, int):
|
||||
reply_value = ord(reply_bytes[:1]) & self.mask
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("BooleanValidator: validate read %r => %02X",
|
||||
_log.debug('BooleanValidator: validate read %r => %02X',
|
||||
reply_bytes, reply_value)
|
||||
if reply_value == self.true_value:
|
||||
return True
|
||||
if reply_value == self.false_value:
|
||||
return False
|
||||
_log.warn("BooleanValidator: reply %02X mismatched %02X/%02X/%02X",
|
||||
_log.warn('BooleanValidator: reply %02X mismatched %02X/%02X/%02X',
|
||||
reply_value, self.true_value, self.false_value,
|
||||
self.mask)
|
||||
return False
|
||||
|
@ -606,7 +606,7 @@ class BooleanValidator(object):
|
|||
if reply_value == false_value:
|
||||
return False
|
||||
|
||||
_log.warn("BooleanValidator: reply %r mismatched %r/%r/%r",
|
||||
_log.warn('BooleanValidator: reply %r mismatched %r/%r/%r',
|
||||
reply_bytes, self.true_value, self.false_value, self.mask)
|
||||
return False
|
||||
|
||||
|
@ -642,7 +642,7 @@ class BooleanValidator(object):
|
|||
return None
|
||||
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("BooleanValidator: prepare_write(%s, %s) => %r",
|
||||
_log.debug('BooleanValidator: prepare_write(%s, %s) => %r',
|
||||
new_value, current_value, to_write)
|
||||
|
||||
return to_write
|
||||
|
@ -706,7 +706,7 @@ class ChoicesValidator(object):
|
|||
def validate_read(self, reply_bytes):
|
||||
reply_value = _bytes2int(reply_bytes[:self._bytes_count])
|
||||
valid_value = self.choices[reply_value]
|
||||
assert valid_value is not None, "%s: failed to validate read value %02X" % (
|
||||
assert valid_value is not None, '%s: failed to validate read value %02X' % (
|
||||
self.__class__.__name__, reply_value)
|
||||
return valid_value
|
||||
|
||||
|
@ -724,7 +724,7 @@ class ChoicesValidator(object):
|
|||
raise ValueError(new_value)
|
||||
|
||||
if choice is None:
|
||||
raise ValueError("invalid choice %r" % new_value)
|
||||
raise ValueError('invalid choice %r' % new_value)
|
||||
assert isinstance(choice, _NamedInt)
|
||||
return choice.bytes(self._bytes_count)
|
||||
|
||||
|
@ -772,14 +772,14 @@ class ChoicesMapValidator(ChoicesValidator):
|
|||
if self.extra_default is not None and self.extra_default == reply_value:
|
||||
return int(self.choices[key][0])
|
||||
assert reply_value in self.choices[
|
||||
key], "%s: failed to validate read value %02X" % (
|
||||
key], '%s: failed to validate read value %02X' % (
|
||||
self.__class__.__name__, reply_value)
|
||||
return reply_value
|
||||
|
||||
def prepare_write(self, key, new_value):
|
||||
choices = self.choices[key]
|
||||
if new_value not in choices and new_value != self.extra_default:
|
||||
raise ValueError("invalid choice %r" % new_value)
|
||||
raise ValueError('invalid choice %r' % new_value)
|
||||
return _int2bytes(new_value,
|
||||
self._skip_bytes_count + self._value_bytes_count)
|
||||
|
||||
|
@ -808,13 +808,13 @@ class RangeValidator(object):
|
|||
|
||||
def validate_read(self, reply_bytes):
|
||||
reply_value = _bytes2int(reply_bytes[:self._bytes_count])
|
||||
assert reply_value >= self.min_value, "%s: failed to validate read value %02X" % (
|
||||
assert reply_value >= self.min_value, '%s: failed to validate read value %02X' % (
|
||||
self.__class__.__name__, reply_value)
|
||||
assert reply_value <= self.max_value, "%s: failed to validate read value %02X" % (
|
||||
assert reply_value <= self.max_value, '%s: failed to validate read value %02X' % (
|
||||
self.__class__.__name__, reply_value)
|
||||
return reply_value
|
||||
|
||||
def prepare_write(self, new_value, current_value=None):
|
||||
if new_value < self.min_value or new_value > self.max_value:
|
||||
raise ValueError("invalid choice %r" % new_value)
|
||||
raise ValueError('invalid choice %r' % new_value)
|
||||
return _int2bytes(new_value, self._bytes_count)
|
||||
|
|
|
@ -314,48 +314,48 @@ def feature_range(name,
|
|||
#
|
||||
|
||||
_HAND_DETECTION = (
|
||||
'hand-detection', _("Hand Detection"),
|
||||
_("Turn on illumination when the hands hover over the keyboard."))
|
||||
'hand-detection', _('Hand Detection'),
|
||||
_('Turn on illumination when the hands hover over the keyboard.'))
|
||||
_SMOOTH_SCROLL = (
|
||||
'smooth-scroll', _("Smooth Scrolling"),
|
||||
_("High-sensitivity mode for vertical scroll with the wheel."))
|
||||
'smooth-scroll', _('Smooth Scrolling'),
|
||||
_('High-sensitivity mode for vertical scroll with the wheel.'))
|
||||
_SIDE_SCROLL = (
|
||||
'side-scroll', _("Side Scrolling"),
|
||||
_("When disabled, pushing the wheel sideways sends custom button events\n"
|
||||
"instead of the standard side-scrolling events."))
|
||||
'side-scroll', _('Side Scrolling'),
|
||||
_('When disabled, pushing the wheel sideways sends custom button events\n'
|
||||
'instead of the standard side-scrolling events.'))
|
||||
_HI_RES_SCROLL = (
|
||||
'hi-res-scroll', _("High Resolution Scrolling"),
|
||||
_("High-sensitivity mode for vertical scroll with the wheel."))
|
||||
_LOW_RES_SCROLL = ('lowres-smooth-scroll', _("HID++ Scrolling"),
|
||||
_("HID++ mode for vertical scroll with the wheel.") + '\n' +
|
||||
_("Effectively turns off wheel scrolling in Linux."))
|
||||
_HIRES_INV = ('hires-smooth-invert', _("High Resolution Wheel Invert"),
|
||||
_("High-sensitivity wheel invert mode for vertical scroll."))
|
||||
_HIRES_RES = ('hires-smooth-resolution', _("Wheel Resolution"),
|
||||
_("High-sensitivity mode for vertical scroll with the wheel."))
|
||||
'hi-res-scroll', _('High Resolution Scrolling'),
|
||||
_('High-sensitivity mode for vertical scroll with the wheel.'))
|
||||
_LOW_RES_SCROLL = ('lowres-smooth-scroll', _('HID++ Scrolling'),
|
||||
_('HID++ mode for vertical scroll with the wheel.') + '\n' +
|
||||
_('Effectively turns off wheel scrolling in Linux.'))
|
||||
_HIRES_INV = ('hires-smooth-invert', _('High Resolution Wheel Invert'),
|
||||
_('High-sensitivity wheel invert mode for vertical scroll.'))
|
||||
_HIRES_RES = ('hires-smooth-resolution', _('Wheel Resolution'),
|
||||
_('High-sensitivity mode for vertical scroll with the wheel.'))
|
||||
_FN_SWAP = (
|
||||
'fn-swap', _("Swap Fx function"),
|
||||
_("When set, the F1..F12 keys will activate their special function,\n"
|
||||
"and you must hold the FN key to activate their standard function.") +
|
||||
'fn-swap', _('Swap Fx function'),
|
||||
_('When set, the F1..F12 keys will activate their special function,\n'
|
||||
'and you must hold the FN key to activate their standard function.') +
|
||||
'\n\n' +
|
||||
_("When unset, the F1..F12 keys will activate their standard function,\n"
|
||||
"and you must hold the FN key to activate their special function."))
|
||||
_DPI = ('dpi', _("Sensitivity (DPI)"), None)
|
||||
_POINTER_SPEED = ('pointer_speed', _("Sensitivity (Pointer Speed)"),
|
||||
_("Speed multiplier for mouse (256 is normal multiplier)."))
|
||||
_('When unset, the F1..F12 keys will activate their standard function,\n'
|
||||
'and you must hold the FN key to activate their special function.'))
|
||||
_DPI = ('dpi', _('Sensitivity (DPI)'), None)
|
||||
_POINTER_SPEED = ('pointer_speed', _('Sensitivity (Pointer Speed)'),
|
||||
_('Speed multiplier for mouse (256 is normal multiplier).'))
|
||||
_SMART_SHIFT = (
|
||||
'smart-shift', _("Smart Shift"),
|
||||
_("Automatically switch the mouse wheel between ratchet and freespin mode.\n"
|
||||
"The mouse wheel is always free at 0, and always locked at 50"))
|
||||
_BACKLIGHT = ('backlight', _("Backlight"),
|
||||
_("Turn illumination on or off on keyboard."))
|
||||
'smart-shift', _('Smart Shift'),
|
||||
_('Automatically switch the mouse wheel between ratchet and freespin mode.\n'
|
||||
'The mouse wheel is always free at 0, and always locked at 50'))
|
||||
_BACKLIGHT = ('backlight', _('Backlight'),
|
||||
_('Turn illumination on or off on keyboard.'))
|
||||
_REPROGRAMMABLE_KEYS = ('reprogrammable-keys', _(
|
||||
"Actions"
|
||||
), _("Change the action for the key or button.") + "\n" + _(
|
||||
"Changing important actions (such as for the left mouse button) can result in an unusable system."
|
||||
'Actions'
|
||||
), _('Change the action for the key or button.') + '\n' + _(
|
||||
'Changing important actions (such as for the left mouse button) can result in an unusable system.'
|
||||
))
|
||||
_DISABLE_KEYS = ('disable-keyboard-keys', _("Disable keys"),
|
||||
_("Disable specific keyboard keys."))
|
||||
_DISABLE_KEYS = ('disable-keyboard-keys', _('Disable keys'),
|
||||
_('Disable specific keyboard keys.'))
|
||||
|
||||
#
|
||||
#
|
||||
|
@ -741,12 +741,12 @@ def check_feature_settings(device, already_known):
|
|||
try:
|
||||
detected = featureFn()(device)
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("check_feature[%s] detected %s", featureId,
|
||||
_log.debug('check_feature[%s] detected %s', featureId,
|
||||
detected)
|
||||
if detected:
|
||||
already_known.append(detected)
|
||||
except Exception as reason:
|
||||
_log.error("check_feature[%s] inconsistent feature %s", featureId,
|
||||
_log.error('check_feature[%s] inconsistent feature %s', featureId,
|
||||
reason)
|
||||
|
||||
for name, featureId, featureFn, _, _ in _SETTINGS_TABLE:
|
||||
|
|
|
@ -106,8 +106,8 @@ class ReceiverStatus(dict):
|
|||
|
||||
def __str__(self):
|
||||
count = len(self._receiver)
|
||||
return (_("No paired devices.") if count == 0 else ngettext(
|
||||
"%(count)s paired device.", "%(count)s paired devices.", count) % {
|
||||
return (_('No paired devices.') if count == 0 else ngettext(
|
||||
'%(count)s paired device.', '%(count)s paired devices.', count) % {
|
||||
'count': count
|
||||
})
|
||||
|
||||
|
@ -161,11 +161,11 @@ class DeviceStatus(dict):
|
|||
battery_level = self.get(KEYS.BATTERY_LEVEL)
|
||||
if battery_level is not None:
|
||||
if isinstance(battery_level, _NamedInt):
|
||||
yield _("Battery: %(level)s") % {
|
||||
yield _('Battery: %(level)s') % {
|
||||
'level': _(str(battery_level))
|
||||
}
|
||||
else:
|
||||
yield _("Battery: %(percent)d%%") % {
|
||||
yield _('Battery: %(percent)d%%') % {
|
||||
'percent': battery_level
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ class DeviceStatus(dict):
|
|||
light_level = self.get(KEYS.LIGHT_LEVEL)
|
||||
if light_level is not None:
|
||||
if comma: yield ', '
|
||||
yield _("Lighting: %(level)s lux") % {'level': light_level}
|
||||
yield _('Lighting: %(level)s lux') % {'level': light_level}
|
||||
|
||||
return ''.join(i for i in _items())
|
||||
|
||||
|
@ -198,7 +198,7 @@ class DeviceStatus(dict):
|
|||
voltage=None,
|
||||
timestamp=None):
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("%s: battery %s, %s", self._device, level, status)
|
||||
_log.debug('%s: battery %s, %s', self._device, level, status)
|
||||
|
||||
if level is None:
|
||||
# Some notifications may come with no battery level info, just
|
||||
|
@ -239,19 +239,19 @@ class DeviceStatus(dict):
|
|||
level > _BATTERY_ATTENTION_LEVEL):
|
||||
self[KEYS.ERROR] = None
|
||||
else:
|
||||
_log.warn("%s: battery %d%%, ALERT %s", self._device, level,
|
||||
_log.warn('%s: battery %d%%, ALERT %s', self._device, level,
|
||||
status)
|
||||
if self.get(KEYS.ERROR) != status:
|
||||
self[KEYS.ERROR] = status
|
||||
# only show the notification once
|
||||
alert = ALERT.NOTIFICATION | ALERT.ATTENTION
|
||||
if isinstance(level, _NamedInt):
|
||||
reason = _("Battery: %(level)s (%(status)s)") % {
|
||||
reason = _('Battery: %(level)s (%(status)s)') % {
|
||||
'level': _(level),
|
||||
'status': _(status)
|
||||
}
|
||||
else:
|
||||
reason = _("Battery: %(percent)d%% (%(status)s)") % {
|
||||
reason = _('Battery: %(percent)d%% (%(status)s)') % {
|
||||
'percent': level,
|
||||
'status': status.name
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ class DeviceStatus(dict):
|
|||
# Devices lose configuration when they are turned off,
|
||||
# make sure they're up-to-date.
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("%s pushing device settings %s", d,
|
||||
_log.debug('%s pushing device settings %s', d,
|
||||
d.settings)
|
||||
for s in d.settings:
|
||||
s.apply()
|
||||
|
|
|
@ -113,12 +113,12 @@ def _receivers(dev_path=None):
|
|||
try:
|
||||
r = Receiver.open(dev_info)
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("[%s] => %s", dev_info.path, r)
|
||||
_log.debug('[%s] => %s', dev_info.path, r)
|
||||
if r:
|
||||
yield r
|
||||
except Exception as e:
|
||||
_log.exception('opening ' + str(dev_info))
|
||||
_sys.exit("%s: error: %s" % (NAME, str(e)))
|
||||
_sys.exit('%s: error: %s' % (NAME, str(e)))
|
||||
|
||||
|
||||
def _find_receiver(receivers, name):
|
||||
|
|
|
@ -127,7 +127,7 @@ def run(receivers, args, find_receiver, find_device):
|
|||
raise Exception("can't interpret '%s' as integer" % args.value)
|
||||
|
||||
else:
|
||||
raise Exception("NotImplemented")
|
||||
raise Exception('NotImplemented')
|
||||
|
||||
result = setting.write(value)
|
||||
if result is None:
|
||||
|
|
|
@ -96,6 +96,6 @@ def run(receivers, args, find_receiver, _ignore):
|
|||
else:
|
||||
error = receiver.status.get(_status.KEYS.ERROR)
|
||||
if error:
|
||||
raise Exception("pairing failed: %s" % error)
|
||||
raise Exception('pairing failed: %s' % error)
|
||||
else:
|
||||
print('Paired a device') # this is better than an error
|
||||
|
|
|
@ -48,32 +48,32 @@ def run(receivers, args, find_receiver, _ignore):
|
|||
|
||||
print(' Register Dump')
|
||||
register = receiver.read_register(_R.notifications)
|
||||
print(" Notification Register %#04x: %s" %
|
||||
print(' Notification Register %#04x: %s' %
|
||||
(_R.notifications % 0x100,
|
||||
'0x' + _strhex(register) if register else "None"))
|
||||
'0x' + _strhex(register) if register else 'None'))
|
||||
register = receiver.read_register(_R.receiver_connection)
|
||||
print(" Connection State %#04x: %s" %
|
||||
print(' Connection State %#04x: %s' %
|
||||
(_R.receiver_connection % 0x100,
|
||||
'0x' + _strhex(register) if register else "None"))
|
||||
'0x' + _strhex(register) if register else 'None'))
|
||||
register = receiver.read_register(_R.devices_activity)
|
||||
print(" Device Activity %#04x: %s" %
|
||||
print(' Device Activity %#04x: %s' %
|
||||
(_R.devices_activity % 0x100,
|
||||
'0x' + _strhex(register) if register else "None"))
|
||||
'0x' + _strhex(register) if register else 'None'))
|
||||
|
||||
for device in range(0, 6):
|
||||
for sub_reg in [0x0, 0x10, 0x20, 0x30]:
|
||||
register = receiver.read_register(_R.receiver_info,
|
||||
sub_reg + device)
|
||||
print(" Pairing Register %#04x %#04x: %s" %
|
||||
print(' Pairing Register %#04x %#04x: %s' %
|
||||
(_R.receiver_info % 0x100, sub_reg + device,
|
||||
'0x' + _strhex(register) if register else "None"))
|
||||
'0x' + _strhex(register) if register else 'None'))
|
||||
register = receiver.read_register(_R.receiver_info, 0x40 + device)
|
||||
print(" Pairing Name %#04x %#02x: %s" %
|
||||
print(' Pairing Name %#04x %#02x: %s' %
|
||||
(_R.receiver_info % 0x100, 0x40 + device,
|
||||
register[2:2 + ord(register[1:2])] if register else "None"))
|
||||
register[2:2 + ord(register[1:2])] if register else 'None'))
|
||||
|
||||
for sub_reg in range(0, 5):
|
||||
register = receiver.read_register(_R.firmware, sub_reg)
|
||||
print(" Firmware %#04x %#04x: %s" %
|
||||
print(' Firmware %#04x %#04x: %s' %
|
||||
(_R.firmware % 0x100, sub_reg,
|
||||
'0x' + _strhex(register) if register else "None"))
|
||||
'0x' + _strhex(register) if register else 'None'))
|
||||
|
|
|
@ -124,79 +124,79 @@ def _print_device(dev):
|
|||
wheel = _hidpp20.get_hires_wheel(dev)
|
||||
if wheel:
|
||||
multi, has_invert, has_switch, inv, res, target, ratchet = wheel
|
||||
print(" Multiplier: %s" % multi)
|
||||
print(' Multiplier: %s' % multi)
|
||||
if has_invert:
|
||||
print(" Has invert")
|
||||
print(' Has invert')
|
||||
if inv:
|
||||
print(" Inverse wheel motion")
|
||||
print(' Inverse wheel motion')
|
||||
else:
|
||||
print(" Normal wheel motion")
|
||||
print(' Normal wheel motion')
|
||||
if has_switch:
|
||||
print(" Has ratchet switch")
|
||||
print(' Has ratchet switch')
|
||||
if ratchet:
|
||||
print(" Normal wheel mode")
|
||||
print(' Normal wheel mode')
|
||||
else:
|
||||
print(" Free wheel mode")
|
||||
print(' Free wheel mode')
|
||||
if res:
|
||||
print(" High resolution mode")
|
||||
print(' High resolution mode')
|
||||
else:
|
||||
print(" Low resolution mode")
|
||||
print(' Low resolution mode')
|
||||
if target:
|
||||
print(" HID++ notification")
|
||||
print(' HID++ notification')
|
||||
else:
|
||||
print(" HID notification")
|
||||
print(' HID notification')
|
||||
elif feature == _hidpp20.FEATURE.MOUSE_POINTER:
|
||||
mouse_pointer = _hidpp20.get_mouse_pointer_info(dev)
|
||||
if mouse_pointer:
|
||||
print(" DPI: %s" % mouse_pointer['dpi'])
|
||||
print(" Acceleration: %s" %
|
||||
print(' DPI: %s' % mouse_pointer['dpi'])
|
||||
print(' Acceleration: %s' %
|
||||
mouse_pointer['acceleration'])
|
||||
if mouse_pointer['suggest_os_ballistics']:
|
||||
print(" Use OS ballistics")
|
||||
print(' Use OS ballistics')
|
||||
else:
|
||||
print(" Override OS ballistics")
|
||||
print(' Override OS ballistics')
|
||||
if mouse_pointer['suggest_vertical_orientation']:
|
||||
print(" Provide vertical tuning, trackball")
|
||||
print(' Provide vertical tuning, trackball')
|
||||
else:
|
||||
print(" No vertical tuning, standard mice")
|
||||
print(' No vertical tuning, standard mice')
|
||||
if feature == _hidpp20.FEATURE.VERTICAL_SCROLLING:
|
||||
vertical_scrolling_info = _hidpp20.get_vertical_scrolling_info(
|
||||
dev)
|
||||
if vertical_scrolling_info:
|
||||
print(" Roller type: %s" %
|
||||
print(' Roller type: %s' %
|
||||
vertical_scrolling_info['roller'])
|
||||
print(" Ratchet per turn: %s" %
|
||||
print(' Ratchet per turn: %s' %
|
||||
vertical_scrolling_info['ratchet'])
|
||||
print(" Scroll lines: %s" %
|
||||
print(' Scroll lines: %s' %
|
||||
vertical_scrolling_info['lines'])
|
||||
elif feature == _hidpp20.FEATURE.HI_RES_SCROLLING:
|
||||
scrolling_mode, scrolling_resolution = _hidpp20.get_hi_res_scrolling_info(
|
||||
dev)
|
||||
if scrolling_mode:
|
||||
print(" Hi-res scrolling enabled")
|
||||
print(' Hi-res scrolling enabled')
|
||||
else:
|
||||
print(" Hi-res scrolling disabled")
|
||||
print(' Hi-res scrolling disabled')
|
||||
if scrolling_resolution:
|
||||
print(" Hi-res scrolling multiplier: %s" %
|
||||
print(' Hi-res scrolling multiplier: %s' %
|
||||
scrolling_resolution)
|
||||
elif feature == _hidpp20.FEATURE.POINTER_SPEED:
|
||||
pointer_speed = _hidpp20.get_pointer_speed_info(dev)
|
||||
if pointer_speed:
|
||||
print(" Pointer Speed: %s" % pointer_speed)
|
||||
print(' Pointer Speed: %s' % pointer_speed)
|
||||
elif feature == _hidpp20.FEATURE.LOWRES_WHEEL:
|
||||
wheel_status = _hidpp20.get_lowres_wheel_status(dev)
|
||||
if wheel_status:
|
||||
print(" Wheel Reports: %s" % wheel_status)
|
||||
print(' Wheel Reports: %s' % wheel_status)
|
||||
elif feature == _hidpp20.FEATURE.NEW_FN_INVERSION:
|
||||
inverted, default_inverted = _hidpp20.get_new_fn_inversion(dev)
|
||||
print(" Fn-swap:",
|
||||
"enabled" if inverted else "disabled")
|
||||
print(" Fn-swap default:",
|
||||
"enabled" if default_inverted else "disabled")
|
||||
print(' Fn-swap:',
|
||||
'enabled' if inverted else 'disabled')
|
||||
print(' Fn-swap default:',
|
||||
'enabled' if default_inverted else 'disabled')
|
||||
for setting in dev_settings:
|
||||
if setting.feature == feature:
|
||||
v = setting.read(False)
|
||||
print(" %s: %s" % (setting.label, v))
|
||||
print(' %s: %s' % (setting.label, v))
|
||||
|
||||
if dev.online and dev.keys:
|
||||
print(' Has %d reprogrammable keys:' % len(dev.keys))
|
||||
|
|
|
@ -47,14 +47,14 @@ def _load():
|
|||
with open(_file_path, 'r') as config_file:
|
||||
loaded_configuration = _json_load(config_file)
|
||||
except:
|
||||
_log.error("failed to load from %s", _file_path)
|
||||
_log.error('failed to load from %s', _file_path)
|
||||
|
||||
# loaded_configuration.update(_configuration)
|
||||
_configuration.clear()
|
||||
_configuration.update(loaded_configuration)
|
||||
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("load => %s", _configuration)
|
||||
_log.debug('load => %s', _configuration)
|
||||
|
||||
_cleanup(_configuration)
|
||||
_configuration[_KEY_VERSION] = __version__
|
||||
|
@ -71,7 +71,7 @@ def save():
|
|||
try:
|
||||
_os.makedirs(dirname)
|
||||
except:
|
||||
_log.error("failed to create %s", dirname)
|
||||
_log.error('failed to create %s', dirname)
|
||||
return False
|
||||
|
||||
_cleanup(_configuration)
|
||||
|
@ -85,10 +85,10 @@ def save():
|
|||
sort_keys=True)
|
||||
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info("saved %s to %s", _configuration, _file_path)
|
||||
_log.info('saved %s to %s', _configuration, _file_path)
|
||||
return True
|
||||
except:
|
||||
_log.error("failed to save to %s", _file_path)
|
||||
_log.error('failed to save to %s', _file_path)
|
||||
|
||||
|
||||
def _cleanup(d):
|
||||
|
|
|
@ -39,7 +39,7 @@ def _require(module, os_package, gi=None, gi_package=None, gi_version=None):
|
|||
return importlib.import_module(module)
|
||||
except (ImportError, ValueError):
|
||||
import sys
|
||||
sys.exit("%s: missing required system package %s" % (NAME, os_package))
|
||||
sys.exit('%s: missing required system package %s' % (NAME, os_package))
|
||||
|
||||
|
||||
prefer_symbolic_battery_icons = False
|
||||
|
@ -115,7 +115,7 @@ def _parse_arguments():
|
|||
|
||||
if not args.action:
|
||||
if logging.root.isEnabledFor(logging.INFO):
|
||||
logging.info("language %s (%s), translations path %s",
|
||||
logging.info('language %s (%s), translations path %s',
|
||||
_i18n.language, _i18n.encoding, _i18n.path)
|
||||
|
||||
return args
|
||||
|
|
|
@ -84,7 +84,7 @@ class ReceiverListener(_listener.EventsListener):
|
|||
|
||||
def has_started(self):
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info("%s: notifications listener has started (%s)",
|
||||
_log.info('%s: notifications listener has started (%s)',
|
||||
self.receiver, self.receiver.handle)
|
||||
notification_flags = self.receiver.enable_notifications()
|
||||
self.receiver.status[
|
||||
|
@ -96,18 +96,18 @@ class ReceiverListener(_listener.EventsListener):
|
|||
r, self.receiver = self.receiver, None
|
||||
assert r is not None
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info("%s: notifications listener has stopped", r)
|
||||
_log.info('%s: notifications listener has stopped', r)
|
||||
|
||||
# because udev is not notifying us about device removal,
|
||||
# make sure to clean up in _all_listeners
|
||||
_all_listeners.pop(r.path, None)
|
||||
|
||||
r.status = _("The receiver was unplugged.")
|
||||
r.status = _('The receiver was unplugged.')
|
||||
if r:
|
||||
try:
|
||||
r.close()
|
||||
except:
|
||||
_log.exception("closing receiver %s" % r.path)
|
||||
_log.exception('closing receiver %s' % r.path)
|
||||
self.status_changed_callback(r) #, _status.ALERT.NOTIFICATION)
|
||||
|
||||
# def tick(self, timestamp):
|
||||
|
@ -151,11 +151,11 @@ class ReceiverListener(_listener.EventsListener):
|
|||
assert device is not None
|
||||
if _log.isEnabledFor(_INFO):
|
||||
if device.kind is None:
|
||||
_log.info("status_changed %s: %s, %s (%X) %s", device,
|
||||
_log.info('status_changed %s: %s, %s (%X) %s', device,
|
||||
'present' if bool(device) else 'removed',
|
||||
device.status, alert, reason or '')
|
||||
else:
|
||||
_log.info("status_changed %s: %s %s, %s (%X) %s", device,
|
||||
_log.info('status_changed %s: %s %s, %s (%X) %s', device,
|
||||
'paired' if bool(device) else 'unpaired',
|
||||
'online' if device.online else 'offline',
|
||||
device.status, alert, reason or '')
|
||||
|
@ -171,7 +171,7 @@ class ReceiverListener(_listener.EventsListener):
|
|||
# Device was unpaired, and isn't valid anymore.
|
||||
# We replace it with a ghost so that the UI has something to work
|
||||
# with while cleaning up.
|
||||
_log.warn("device %s was unpaired, ghosting", device)
|
||||
_log.warn('device %s was unpaired, ghosting', device)
|
||||
device = _ghost(device)
|
||||
|
||||
self.status_changed_callback(device, alert, reason)
|
||||
|
@ -194,7 +194,7 @@ class ReceiverListener(_listener.EventsListener):
|
|||
if not (0 < n.devnumber <= self.receiver.max_devices):
|
||||
if _log.isEnabledFor(_WARNING):
|
||||
_log.warning(
|
||||
_("Unexpected device number (%s) in notification %s." %
|
||||
_('Unexpected device number (%s) in notification %s.' %
|
||||
(n.devnumber, n)))
|
||||
return
|
||||
already_known = n.devnumber in self.receiver
|
||||
|
@ -231,14 +231,14 @@ class ReceiverListener(_listener.EventsListener):
|
|||
dev = self.receiver[n.devnumber]
|
||||
|
||||
if not dev:
|
||||
_log.warn("%s: received %s for invalid device %d: %r",
|
||||
_log.warn('%s: received %s for invalid device %d: %r',
|
||||
self.receiver, n, n.devnumber, dev)
|
||||
return
|
||||
|
||||
# Apply settings every time the device connects
|
||||
if n.sub_id == 0x41:
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info("%s triggered new device %s (%s)", n, dev, dev.kind)
|
||||
_log.info('%s triggered new device %s (%s)', n, dev, dev.kind)
|
||||
# If there are saved configs, bring the device's settings up-to-date.
|
||||
# They will be applied when the device is marked as online.
|
||||
configuration.attach_to(dev)
|
||||
|
@ -253,7 +253,7 @@ class ReceiverListener(_listener.EventsListener):
|
|||
# this should be the first notification after a device was paired
|
||||
assert n.sub_id == 0x41 and n.address == 0x04
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info("%s: pairing detected new device", self.receiver)
|
||||
_log.info('%s: pairing detected new device', self.receiver)
|
||||
self.receiver.status.new_device = dev
|
||||
elif dev.online is None:
|
||||
dev.ping()
|
||||
|
@ -283,7 +283,7 @@ def _start(device_info):
|
|||
_all_listeners[device_info.path] = rl
|
||||
return rl
|
||||
|
||||
_log.warn("failed to open %s", device_info)
|
||||
_log.warn('failed to open %s', device_info)
|
||||
|
||||
|
||||
def start_all():
|
||||
|
@ -291,7 +291,7 @@ def start_all():
|
|||
stop_all()
|
||||
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info("starting receiver listening threads")
|
||||
_log.info('starting receiver listening threads')
|
||||
for device_info in _base.receivers():
|
||||
_process_receiver_event('add', device_info)
|
||||
|
||||
|
@ -302,7 +302,7 @@ def stop_all():
|
|||
|
||||
if listeners:
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info("stopping receiver listening threads %s", listeners)
|
||||
_log.info('stopping receiver listening threads %s', listeners)
|
||||
|
||||
for l in listeners:
|
||||
l.stop()
|
||||
|
@ -352,7 +352,7 @@ def _process_receiver_event(action, device_info):
|
|||
assert _error_callback
|
||||
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info("receiver event %s %s", action, device_info)
|
||||
_log.info('receiver event %s %s', action, device_info)
|
||||
|
||||
# whatever the action, stop any previous receivers at this path
|
||||
l = _all_listeners.pop(device_info.path, None)
|
||||
|
|
|
@ -56,7 +56,7 @@ class TaskRunner(_Thread):
|
|||
self.alive = True
|
||||
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("started")
|
||||
_log.debug('started')
|
||||
|
||||
while self.alive:
|
||||
task = self.queue.get()
|
||||
|
@ -66,7 +66,7 @@ class TaskRunner(_Thread):
|
|||
try:
|
||||
function(*args, **kwargs)
|
||||
except:
|
||||
_log.exception("calling %s", function)
|
||||
_log.exception('calling %s', function)
|
||||
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("stopped")
|
||||
_log.debug('stopped')
|
||||
|
|
|
@ -43,18 +43,18 @@ GLib.threads_init()
|
|||
|
||||
|
||||
def _error_dialog(reason, object):
|
||||
_log.error("error: %s %s", reason, object)
|
||||
_log.error('error: %s %s', reason, object)
|
||||
|
||||
if reason == 'permissions':
|
||||
title = _("Permissions error")
|
||||
text = _("Found a Logitech Receiver (%s), but did not have permission to open it.") % object + \
|
||||
title = _('Permissions error')
|
||||
text = _('Found a Logitech Receiver (%s), but did not have permission to open it.') % object + \
|
||||
'\n\n' + \
|
||||
_("If you've just installed Solaar, try removing the receiver and plugging it back in.")
|
||||
elif reason == 'unpair':
|
||||
title = _("Unpairing failed")
|
||||
text = _("Failed to unpair %{device} from %{receiver}.").format(device=object.name, receiver=object.receiver.name) + \
|
||||
title = _('Unpairing failed')
|
||||
text = _('Failed to unpair %{device} from %{receiver}.').format(device=object.name, receiver=object.receiver.name) + \
|
||||
'\n\n' + \
|
||||
_("The receiver returned an error, with no further details.")
|
||||
_('The receiver returned an error, with no further details.')
|
||||
else:
|
||||
raise Exception("ui.error_dialog: don't know how to handle (%s, %s)",
|
||||
reason, object)
|
||||
|
@ -95,7 +95,7 @@ from . import notify, tray, window # isort:skip # noqa: E402
|
|||
|
||||
def _startup(app, startup_hook, use_tray, show_window):
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("startup registered=%s, remote=%s", app.get_is_registered(),
|
||||
_log.debug('startup registered=%s, remote=%s', app.get_is_registered(),
|
||||
app.get_is_remote())
|
||||
|
||||
from solaar.tasks import TaskRunner as _TaskRunner
|
||||
|
@ -113,7 +113,7 @@ def _startup(app, startup_hook, use_tray, show_window):
|
|||
|
||||
def _activate(app):
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("activate")
|
||||
_log.debug('activate')
|
||||
if app.get_windows():
|
||||
window.popup()
|
||||
else:
|
||||
|
@ -122,14 +122,14 @@ def _activate(app):
|
|||
|
||||
def _command_line(app, command_line):
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("command_line %s", command_line.get_arguments())
|
||||
_log.debug('command_line %s', command_line.get_arguments())
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
def _shutdown(app, shutdown_hook):
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("shutdown")
|
||||
_log.debug('shutdown')
|
||||
|
||||
shutdown_hook()
|
||||
|
||||
|
@ -167,7 +167,7 @@ def run_loop(startup_hook, shutdown_hook, use_tray, show_window, args=None):
|
|||
def _status_changed(device, alert, reason):
|
||||
assert device is not None
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("status changed: %s (%s) %s", device, alert, reason)
|
||||
_log.debug('status changed: %s (%s) %s', device, alert, reason)
|
||||
|
||||
tray.update(device)
|
||||
if alert & ALERT.ATTENTION:
|
||||
|
|
|
@ -36,7 +36,7 @@ def _create():
|
|||
about.set_program_name(NAME)
|
||||
about.set_version(__version__)
|
||||
about.set_comments(
|
||||
_("Shows status of devices connected\nthrough wireless Logitech receivers."
|
||||
_('Shows status of devices connected\nthrough wireless Logitech receivers.'
|
||||
))
|
||||
|
||||
about.set_logo_icon_name(NAME.lower())
|
||||
|
@ -46,25 +46,25 @@ def _create():
|
|||
|
||||
about.set_authors(('Daniel Pavel http://github.com/pwr', ))
|
||||
try:
|
||||
about.add_credit_section(_("GUI design"),
|
||||
about.add_credit_section(_('GUI design'),
|
||||
('Julien Gascard', 'Daniel Pavel'))
|
||||
about.add_credit_section(_("Testing"), (
|
||||
about.add_credit_section(_('Testing'), (
|
||||
'Douglas Wagner',
|
||||
'Julien Gascard',
|
||||
'Peter Wu http://www.lekensteyn.nl/logitech-unifying.html',
|
||||
))
|
||||
about.add_credit_section(_("Logitech documentation"), (
|
||||
about.add_credit_section(_('Logitech documentation'), (
|
||||
'Julien Danjou http://julien.danjou.info/blog/2012/logitech-unifying-upower',
|
||||
'Nestor Lopez Casado http://drive.google.com/folderview?id=0BxbRzx7vEV7eWmgwazJ3NUFfQ28',
|
||||
))
|
||||
except TypeError:
|
||||
# gtk3 < ~3.6.4 has incorrect gi bindings
|
||||
import logging
|
||||
logging.exception("failed to fully create the about dialog")
|
||||
logging.exception('failed to fully create the about dialog')
|
||||
except:
|
||||
# the Gtk3 version may be too old, and the function does not exist
|
||||
import logging
|
||||
logging.exception("failed to fully create the about dialog")
|
||||
logging.exception('failed to fully create the about dialog')
|
||||
|
||||
about.set_translator_credits('\n'.join((
|
||||
'gogo (croatian)',
|
||||
|
|
|
@ -68,7 +68,7 @@ def make_toggle(name, label, function, stock_id=None, *args):
|
|||
# toggle_notifications = make_toggle('notifications', 'Notifications', _toggle_notifications)
|
||||
|
||||
about = make('help-about',
|
||||
_("About") + ' ' + NAME,
|
||||
_('About') + ' ' + NAME,
|
||||
_show_about_window,
|
||||
stock_id=Gtk.STOCK_ABOUT)
|
||||
|
||||
|
@ -96,10 +96,10 @@ def unpair(window, device):
|
|||
|
||||
qdialog = Gtk.MessageDialog(window, 0, Gtk.MessageType.QUESTION,
|
||||
Gtk.ButtonsType.NONE,
|
||||
_("Unpair") + ' ' + device.name + ' ?')
|
||||
_('Unpair') + ' ' + device.name + ' ?')
|
||||
qdialog.set_icon_name('remove')
|
||||
qdialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
|
||||
qdialog.add_button(_("Unpair"), Gtk.ResponseType.ACCEPT)
|
||||
qdialog.add_button(_('Unpair'), Gtk.ResponseType.ACCEPT)
|
||||
choice = qdialog.run()
|
||||
qdialog.destroy()
|
||||
if choice == Gtk.ResponseType.ACCEPT:
|
||||
|
|
|
@ -184,11 +184,11 @@ def _create_sbox(s):
|
|||
sbox.pack_start(Gtk.Label(s.label), False, False, 0)
|
||||
|
||||
spinner = Gtk.Spinner()
|
||||
spinner.set_tooltip_text(_("Working") + '...')
|
||||
spinner.set_tooltip_text(_('Working') + '...')
|
||||
|
||||
failed = Gtk.Image.new_from_icon_name('dialog-warning',
|
||||
Gtk.IconSize.SMALL_TOOLBAR)
|
||||
failed.set_tooltip_text(_("Read/write operation failed."))
|
||||
failed.set_tooltip_text(_('Read/write operation failed.'))
|
||||
|
||||
if s.kind == _SETTING_KIND.toggle:
|
||||
control = _create_toggle_control(s)
|
||||
|
@ -220,7 +220,7 @@ def _create_sbox(s):
|
|||
control = _create_map_choice_control(X(s, {'choices': choices}))
|
||||
sbox.pack_end(control, True, True, 0)
|
||||
else:
|
||||
raise Exception("NotImplemented")
|
||||
raise Exception('NotImplemented')
|
||||
|
||||
control.set_sensitive(False) # the first read will enable it
|
||||
sbox.pack_end(spinner, False, False, 0)
|
||||
|
@ -259,7 +259,7 @@ def _update_setting_item(sbox, value, is_online=True):
|
|||
if value.get(kbox.get_active_id()):
|
||||
vbox.set_active_id(str(value.get(kbox.get_active_id())))
|
||||
else:
|
||||
raise Exception("NotImplemented")
|
||||
raise Exception('NotImplemented')
|
||||
control.set_sensitive(True)
|
||||
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ def _look_for_application_icons():
|
|||
|
||||
import sys as _sys
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("sys.path[0] = %s", _sys.path[0])
|
||||
_log.debug('sys.path[0] = %s', _sys.path[0])
|
||||
prefix_share = _path.normpath(
|
||||
_path.join(_path.realpath(_sys.path[0]), '..'))
|
||||
src_share = _path.normpath(
|
||||
|
@ -75,7 +75,7 @@ def _look_for_application_icons():
|
|||
for location in share_solaar:
|
||||
location = _path.join(location, 'icons')
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("looking for icons in %s", location)
|
||||
_log.debug('looking for icons in %s', location)
|
||||
|
||||
if _path.exists(_path.join(location, TRAY_ATTENTION + '.svg')):
|
||||
yield location
|
||||
|
@ -97,7 +97,7 @@ def _init_icon_paths():
|
|||
for p in _look_for_application_icons():
|
||||
_default_theme.prepend_search_path(p)
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("icon theme paths: %s", _default_theme.get_search_path())
|
||||
_log.debug('icon theme paths: %s', _default_theme.get_search_path())
|
||||
|
||||
if gtk.prefer_symbolic_battery_icons:
|
||||
if _default_theme.has_icon('battery-good-symbolic'):
|
||||
|
@ -105,9 +105,9 @@ def _init_icon_paths():
|
|||
_use_symbolic_icons = True
|
||||
return
|
||||
else:
|
||||
_log.warning("failed to detect symbolic icons")
|
||||
_log.warning('failed to detect symbolic icons')
|
||||
if not _default_theme.has_icon('battery-good'):
|
||||
_log.warning("failed to detect icons")
|
||||
_log.warning('failed to detect icons')
|
||||
|
||||
|
||||
#
|
||||
|
@ -118,10 +118,10 @@ def _init_icon_paths():
|
|||
def battery(level=None, charging=False):
|
||||
icon_name = _battery_icon_name(level, charging)
|
||||
if not _default_theme.has_icon(icon_name):
|
||||
_log.warning("icon %s not found in current theme", icon_name)
|
||||
_log.warning('icon %s not found in current theme', icon_name)
|
||||
return TRAY_OKAY # use Solaar icon if battery icon not available
|
||||
elif _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("battery icon for %s:%s = %s", level, charging, icon_name)
|
||||
_log.debug('battery icon for %s:%s = %s', level, charging, icon_name)
|
||||
return icon_name
|
||||
|
||||
|
||||
|
@ -222,4 +222,4 @@ def icon_file(name, size=_LARGE_SIZE):
|
|||
# _log.debug("icon %s(%d) => %s", name, size, file_name)
|
||||
return file_name
|
||||
|
||||
_log.warn("icon %s(%d) not found in current theme", name, size)
|
||||
_log.warn('icon %s(%d) not found in current theme', name, size)
|
||||
|
|
|
@ -57,18 +57,18 @@ if available:
|
|||
if available:
|
||||
if not Notify.is_initted():
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info("starting desktop notifications")
|
||||
_log.info('starting desktop notifications')
|
||||
try:
|
||||
return Notify.init(NAME)
|
||||
except:
|
||||
_log.exception("initializing desktop notifications")
|
||||
_log.exception('initializing desktop notifications')
|
||||
available = False
|
||||
return available and Notify.is_initted()
|
||||
|
||||
def uninit():
|
||||
if available and Notify.is_initted():
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info("stopping desktop notifications")
|
||||
_log.info('stopping desktop notifications')
|
||||
_notifications.clear()
|
||||
Notify.uninit()
|
||||
|
||||
|
@ -95,14 +95,14 @@ if available:
|
|||
|
||||
n.update(NAME, reason, icon_file)
|
||||
n.set_urgency(Notify.Urgency.NORMAL)
|
||||
n.set_hint("desktop-entry", GLib.Variant('s', NAME.lower()))
|
||||
n.set_hint('desktop-entry', GLib.Variant('s', NAME.lower()))
|
||||
|
||||
try:
|
||||
# if _log.isEnabledFor(_DEBUG):
|
||||
# _log.debug("showing %s", n)
|
||||
n.show()
|
||||
except Exception:
|
||||
_log.exception("showing %s", n)
|
||||
_log.exception('showing %s', n)
|
||||
|
||||
def show(dev, reason=None, icon=None):
|
||||
"""Show a notification with title and text."""
|
||||
|
@ -117,11 +117,11 @@ if available:
|
|||
if reason:
|
||||
message = reason
|
||||
elif dev.status is None:
|
||||
message = _("unpaired")
|
||||
message = _('unpaired')
|
||||
elif bool(dev.status):
|
||||
message = dev.status.to_string() or _("connected")
|
||||
message = dev.status.to_string() or _('connected')
|
||||
else:
|
||||
message = _("offline")
|
||||
message = _('offline')
|
||||
|
||||
# we need to use the filename here because the notifications daemon
|
||||
# is an external application that does not know about our icon sets
|
||||
|
@ -131,14 +131,14 @@ if available:
|
|||
n.update(summary, message, icon_file)
|
||||
urgency = Notify.Urgency.LOW if dev.status else Notify.Urgency.NORMAL
|
||||
n.set_urgency(urgency)
|
||||
n.set_hint("desktop-entry", GLib.Variant('s', NAME.lower()))
|
||||
n.set_hint('desktop-entry', GLib.Variant('s', NAME.lower()))
|
||||
|
||||
try:
|
||||
# if _log.isEnabledFor(_DEBUG):
|
||||
# _log.debug("showing %s", n)
|
||||
n.show()
|
||||
except Exception:
|
||||
_log.exception("showing %s", n)
|
||||
_log.exception('showing %s', n)
|
||||
|
||||
else:
|
||||
init = lambda: False
|
||||
|
|
|
@ -70,7 +70,7 @@ def _create_page(assistant, kind, header=None, icon_name=None, text=None):
|
|||
def _check_lock_state(assistant, receiver, count=2):
|
||||
if not assistant.is_drawable():
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("assistant %s destroyed, bailing out", assistant)
|
||||
_log.debug('assistant %s destroyed, bailing out', assistant)
|
||||
return False
|
||||
|
||||
if receiver.status.get(_K.ERROR):
|
||||
|
@ -99,7 +99,7 @@ def _check_lock_state(assistant, receiver, count=2):
|
|||
def _prepare(assistant, page, receiver):
|
||||
index = assistant.get_current_page()
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("prepare %s %d %s", assistant, index, page)
|
||||
_log.debug('prepare %s %d %s', assistant, index, page)
|
||||
|
||||
if index == 0:
|
||||
if receiver.set_lock(False, timeout=_PAIRING_TIMEOUT):
|
||||
|
@ -119,7 +119,7 @@ def _prepare(assistant, page, receiver):
|
|||
|
||||
def _finish(assistant, receiver):
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("finish %s", assistant)
|
||||
_log.debug('finish %s', assistant)
|
||||
assistant.destroy()
|
||||
receiver.status.new_device = None
|
||||
if receiver.status.lock_open:
|
||||
|
@ -130,23 +130,23 @@ def _finish(assistant, receiver):
|
|||
|
||||
def _pairing_failed(assistant, receiver, error):
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("%s fail: %s", receiver, error)
|
||||
_log.debug('%s fail: %s', receiver, error)
|
||||
|
||||
assistant.commit()
|
||||
|
||||
header = _("Pairing failed") + ': ' + _(str(error)) + '.'
|
||||
header = _('Pairing failed') + ': ' + _(str(error)) + '.'
|
||||
if 'timeout' in str(error):
|
||||
text = _(
|
||||
"Make sure your device is within range, and has a decent battery charge."
|
||||
'Make sure your device is within range, and has a decent battery charge.'
|
||||
)
|
||||
elif str(error) == 'device not supported':
|
||||
text = _(
|
||||
"A new device was detected, but it is not compatible with this receiver."
|
||||
'A new device was detected, but it is not compatible with this receiver.'
|
||||
)
|
||||
elif 'many' in str(error):
|
||||
text = _("The receiver only supports %d paired device(s).")
|
||||
text = _('The receiver only supports %d paired device(s).')
|
||||
else:
|
||||
text = _("No further details are available about the error.")
|
||||
text = _('No further details are available about the error.')
|
||||
_create_page(assistant, Gtk.AssistantPageType.SUMMARY, header,
|
||||
'dialog-error', text)
|
||||
|
||||
|
@ -157,11 +157,11 @@ def _pairing_failed(assistant, receiver, error):
|
|||
def _pairing_succeeded(assistant, receiver, device):
|
||||
assert device
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("%s success: %s", receiver, device)
|
||||
_log.debug('%s success: %s', receiver, device)
|
||||
|
||||
page = _create_page(assistant, Gtk.AssistantPageType.SUMMARY)
|
||||
|
||||
header = Gtk.Label(_("Found a new device:"))
|
||||
header = Gtk.Label(_('Found a new device:'))
|
||||
header.set_alignment(0.5, 0)
|
||||
page.pack_start(header, False, False, 0)
|
||||
|
||||
|
@ -190,7 +190,7 @@ def _pairing_succeeded(assistant, receiver, device):
|
|||
Gtk.IconSize.MENU), False,
|
||||
False, 0)
|
||||
hbox.pack_start(
|
||||
Gtk.Label(_("The wireless link is not encrypted") + '!'),
|
||||
Gtk.Label(_('The wireless link is not encrypted') + '!'),
|
||||
False, False, 0)
|
||||
hbox.show_all()
|
||||
else:
|
||||
|
@ -219,14 +219,14 @@ def create(receiver):
|
|||
assistant.set_role('pair-device')
|
||||
|
||||
page_text = _(
|
||||
"If the device is already turned on, turn if off and on again.")
|
||||
'If the device is already turned on, turn if off and on again.')
|
||||
if receiver.remaining_pairings() and receiver.remaining_pairings() >= 0:
|
||||
page_text += _("\n\nThis receiver has %d pairing(s) remaining."
|
||||
page_text += _('\n\nThis receiver has %d pairing(s) remaining.'
|
||||
) % receiver.remaining_pairings()
|
||||
page_text += _("\nCancelling at this point will not use up a pairing.")
|
||||
page_text += _('\nCancelling at this point will not use up a pairing.')
|
||||
|
||||
page_intro = _create_page(assistant, Gtk.AssistantPageType.PROGRESS,
|
||||
_("Turn on the device you want to pair."),
|
||||
_('Turn on the device you want to pair.'),
|
||||
'preferences-desktop-peripherals', page_text)
|
||||
spinner = Gtk.Spinner()
|
||||
spinner.set_visible(True)
|
||||
|
|
|
@ -56,7 +56,7 @@ def _create_menu(quit_handler):
|
|||
|
||||
# per-device menu entries will be generated as-needed
|
||||
|
||||
no_receiver = Gtk.MenuItem.new_with_label(_("No Logitech receiver found"))
|
||||
no_receiver = Gtk.MenuItem.new_with_label(_('No Logitech receiver found'))
|
||||
no_receiver.set_sensitive(False)
|
||||
menu.append(no_receiver)
|
||||
menu.append(Gtk.SeparatorMenuItem.new())
|
||||
|
@ -65,7 +65,7 @@ def _create_menu(quit_handler):
|
|||
menu.append(about.create_menu_item())
|
||||
menu.append(
|
||||
make('application-exit',
|
||||
_("Quit"),
|
||||
_('Quit'),
|
||||
quit_handler,
|
||||
stock_id=Gtk.STOCK_QUIT).create_menu_item())
|
||||
del about, make
|
||||
|
@ -149,7 +149,7 @@ def _scroll(tray_icon, event, direction=None):
|
|||
|
||||
_picked_device = candidate or _picked_device
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("scroll: picked %s", _picked_device)
|
||||
_log.debug('scroll: picked %s', _picked_device)
|
||||
_update_tray_icon()
|
||||
|
||||
|
||||
|
@ -172,7 +172,7 @@ try:
|
|||
from gi.repository import AppIndicator3
|
||||
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("using %sAppIndicator3" %
|
||||
_log.debug('using %sAppIndicator3' %
|
||||
('Ayatana ' if ayatana_appindicator_found else ''))
|
||||
|
||||
# Defense against AppIndicator3 bug that treats files in current directory as icon files
|
||||
|
@ -238,7 +238,7 @@ try:
|
|||
except ImportError:
|
||||
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("using StatusIcon")
|
||||
_log.debug('using StatusIcon')
|
||||
|
||||
def _create(menu):
|
||||
icon = Gtk.StatusIcon.new_from_icon_name(_icons.TRAY_INIT)
|
||||
|
@ -302,7 +302,7 @@ except ImportError:
|
|||
|
||||
def _generate_tooltip_lines():
|
||||
if not _devices_info:
|
||||
yield '<b>%s</b>: ' % NAME + _("no receiver")
|
||||
yield '<b>%s</b>: ' % NAME + _('no receiver')
|
||||
return
|
||||
|
||||
yield from _generate_description_lines()
|
||||
|
@ -310,7 +310,7 @@ def _generate_tooltip_lines():
|
|||
|
||||
def _generate_description_lines():
|
||||
if not _devices_info:
|
||||
yield _("no receiver")
|
||||
yield _('no receiver')
|
||||
return
|
||||
|
||||
for _ignore, number, name, status in _devices_info:
|
||||
|
@ -323,13 +323,13 @@ def _generate_description_lines():
|
|||
if status:
|
||||
yield '\t%s' % p
|
||||
else:
|
||||
yield '\t%s <small>(' % p + _("offline") + ')</small>'
|
||||
yield '\t%s <small>(' % p + _('offline') + ')</small>'
|
||||
else:
|
||||
if status:
|
||||
yield '<b>%s</b> <small>(' % name + _(
|
||||
"no status") + ')</small>'
|
||||
'no status') + ')</small>'
|
||||
else:
|
||||
yield '<b>%s</b> <small>(' % name + _("offline") + ')</small>'
|
||||
yield '<b>%s</b> <small>(' % name + _('offline') + ')</small>'
|
||||
yield ''
|
||||
|
||||
|
||||
|
@ -350,7 +350,7 @@ def _pick_device_with_lowest_battery():
|
|||
picked_level = level or 0
|
||||
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("picked device with lowest battery: %s", picked)
|
||||
_log.debug('picked device with lowest battery: %s', picked)
|
||||
|
||||
return picked
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ _INFO_ICON_SIZE = Gtk.IconSize.LARGE_TOOLBAR
|
|||
_DEVICE_ICON_SIZE = Gtk.IconSize.DND
|
||||
try:
|
||||
import gi
|
||||
gi.check_version("3.7.4")
|
||||
gi.check_version('3.7.4')
|
||||
_CAN_SET_ROW_NONE = None
|
||||
except (ValueError, AttributeError):
|
||||
_CAN_SET_ROW_NONE = ''
|
||||
|
@ -112,7 +112,7 @@ def _create_receiver_panel():
|
|||
p._count.set_alignment(0, 0.5)
|
||||
p.pack_start(p._count, True, True, 0)
|
||||
|
||||
p._scanning = Gtk.Label(_("Scanning") + '...')
|
||||
p._scanning = Gtk.Label(_('Scanning') + '...')
|
||||
p._spinner = Gtk.Spinner()
|
||||
|
||||
bp = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 8)
|
||||
|
@ -145,14 +145,14 @@ def _create_device_panel():
|
|||
|
||||
return b
|
||||
|
||||
p._battery = _status_line(_("Battery"))
|
||||
p._battery = _status_line(_('Battery'))
|
||||
p.pack_start(p._battery, False, False, 0)
|
||||
|
||||
p._secure = _status_line(_("Wireless Link"))
|
||||
p._secure = _status_line(_('Wireless Link'))
|
||||
p._secure._icon.set_from_icon_name('dialog-warning', _INFO_ICON_SIZE)
|
||||
p.pack_start(p._secure, False, False, 0)
|
||||
|
||||
p._lux = _status_line(_("Lighting"))
|
||||
p._lux = _status_line(_('Lighting'))
|
||||
p.pack_start(p._lux, False, False, 0)
|
||||
|
||||
p._config = _config_panel.create()
|
||||
|
@ -183,7 +183,7 @@ def _create_buttons_box():
|
|||
bb._details = _new_button(None,
|
||||
'dialog-information',
|
||||
_SMALL_BUTTON_ICON_SIZE,
|
||||
tooltip=_("Show Technical Details"),
|
||||
tooltip=_('Show Technical Details'),
|
||||
toggle=True,
|
||||
clicked=_update_details)
|
||||
bb.add(bb._details)
|
||||
|
@ -198,7 +198,7 @@ def _create_buttons_box():
|
|||
assert receiver.kind is None
|
||||
_action.pair(_window, receiver)
|
||||
|
||||
bb._pair = _new_button(_("Pair new device"),
|
||||
bb._pair = _new_button(_('Pair new device'),
|
||||
'list-add',
|
||||
clicked=_pair_new_device)
|
||||
bb.add(bb._pair)
|
||||
|
@ -211,7 +211,7 @@ def _create_buttons_box():
|
|||
assert device.kind is not None
|
||||
_action.unpair(_window, device)
|
||||
|
||||
bb._unpair = _new_button(_("Unpair"),
|
||||
bb._unpair = _new_button(_('Unpair'),
|
||||
'edit-delete',
|
||||
clicked=_unpair_current_device)
|
||||
bb.add(bb._unpair)
|
||||
|
@ -221,7 +221,7 @@ def _create_buttons_box():
|
|||
|
||||
def _create_empty_panel():
|
||||
p = Gtk.Label()
|
||||
p.set_markup('<small>' + _("Select a device") + '</small>')
|
||||
p.set_markup('<small>' + _('Select a device') + '</small>')
|
||||
p.set_sensitive(False)
|
||||
|
||||
return p
|
||||
|
@ -339,12 +339,12 @@ def _create_window_layout():
|
|||
bottom_buttons_box = Gtk.ButtonBox(Gtk.Orientation.HORIZONTAL)
|
||||
bottom_buttons_box.set_layout(Gtk.ButtonBoxStyle.START)
|
||||
bottom_buttons_box.set_spacing(20)
|
||||
quit_button = _new_button(_("Quit") + ' ' + NAME,
|
||||
quit_button = _new_button(_('Quit') + ' ' + NAME,
|
||||
'application-exit',
|
||||
icon_size=_SMALL_BUTTON_ICON_SIZE,
|
||||
clicked=destroy)
|
||||
bottom_buttons_box.add(quit_button)
|
||||
about_button = _new_button(_("About") + ' ' + NAME,
|
||||
about_button = _new_button(_('About') + ' ' + NAME,
|
||||
'help-about',
|
||||
icon_size=_SMALL_BUTTON_ICON_SIZE,
|
||||
clicked=_show_about_window)
|
||||
|
@ -444,7 +444,7 @@ def _receiver_row(receiver_path, receiver=None):
|
|||
status_text, status_icon, receiver)
|
||||
assert len(row_data) == len(_TREE_SEPATATOR)
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("new receiver row %s", row_data)
|
||||
_log.debug('new receiver row %s', row_data)
|
||||
item = _model.append(None, row_data)
|
||||
if _TREE_SEPATATOR:
|
||||
_model.append(None, _TREE_SEPATATOR)
|
||||
|
@ -480,7 +480,7 @@ def _device_row(receiver_path, device_number, device=None):
|
|||
device)
|
||||
assert len(row_data) == len(_TREE_SEPATATOR)
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("new device row %s at index %d", row_data,
|
||||
_log.debug('new device row %s at index %d', row_data,
|
||||
new_child_index)
|
||||
item = _model.insert(receiver_row, new_child_index, row_data)
|
||||
|
||||
|
@ -503,7 +503,7 @@ def select(receiver_path, device_number=None):
|
|||
selection = _tree.get_selection()
|
||||
selection.select_iter(item)
|
||||
else:
|
||||
_log.warn("select(%s, %s) failed to find an item", receiver_path,
|
||||
_log.warn('select(%s, %s) failed to find an item', receiver_path,
|
||||
device_number)
|
||||
|
||||
|
||||
|
@ -548,33 +548,33 @@ def _update_details(button):
|
|||
# cached, and involves no HID++ calls.
|
||||
|
||||
if device.kind is None:
|
||||
yield (_("Path"), device.path)
|
||||
yield (_('Path'), device.path)
|
||||
# 046d is the Logitech vendor id
|
||||
yield (_("USB id"), '046d:' + device.product_id)
|
||||
yield (_('USB id'), '046d:' + device.product_id)
|
||||
|
||||
if read_all:
|
||||
yield (_("Serial"), device.serial)
|
||||
yield (_('Serial'), device.serial)
|
||||
else:
|
||||
yield (_("Serial"), '...')
|
||||
yield (_('Serial'), '...')
|
||||
|
||||
else:
|
||||
# yield ('Codename', device.codename)
|
||||
yield (_("Index"), device.number)
|
||||
yield (_("Wireless PID"), device.wpid)
|
||||
yield (_('Index'), device.number)
|
||||
yield (_('Wireless PID'), device.wpid)
|
||||
hid_version = device.protocol
|
||||
yield (_("Protocol"), 'HID++ %1.1f' %
|
||||
yield (_('Protocol'), 'HID++ %1.1f' %
|
||||
hid_version if hid_version else _('Unknown'))
|
||||
if read_all and device.polling_rate:
|
||||
yield (_("Polling rate"),
|
||||
yield (_('Polling rate'),
|
||||
_('%(rate)d ms (%(rate_hz)dHz)') % {
|
||||
'rate': device.polling_rate,
|
||||
'rate_hz': 1000 // device.polling_rate
|
||||
})
|
||||
|
||||
if read_all or not device.online:
|
||||
yield (_("Serial"), device.serial)
|
||||
yield (_('Serial'), device.serial)
|
||||
else:
|
||||
yield (_("Serial"), '...')
|
||||
yield (_('Serial'), '...')
|
||||
|
||||
if read_all:
|
||||
if device.firmware:
|
||||
|
@ -582,15 +582,15 @@ def _update_details(button):
|
|||
yield (' ' + _(str(fw.kind)),
|
||||
(fw.name + ' ' + fw.version).strip())
|
||||
elif device.kind is None or device.online:
|
||||
yield (' %s' % _("Firmware"), '...')
|
||||
yield (' %s' % _('Firmware'), '...')
|
||||
|
||||
flag_bits = device.status.get(_K.NOTIFICATION_FLAGS)
|
||||
if flag_bits is not None:
|
||||
flag_names = (
|
||||
'(%s)' % _("none"),
|
||||
'(%s)' % _('none'),
|
||||
) if flag_bits == 0 else _hidpp10.NOTIFICATION_FLAG.flag_names(
|
||||
flag_bits)
|
||||
yield (_("Notifications"), ('\n%15s' % ' ').join(flag_names))
|
||||
yield (_('Notifications'), ('\n%15s' % ' ').join(flag_names))
|
||||
|
||||
def _set_details(text):
|
||||
_details._text.set_markup(text)
|
||||
|
@ -696,7 +696,7 @@ def _update_device_panel(device, panel, buttons, full=False):
|
|||
panel._battery._icon.set_sensitive(False)
|
||||
panel._battery._icon.set_from_icon_name(icon_name, _INFO_ICON_SIZE)
|
||||
panel._battery._text.set_sensitive(True)
|
||||
panel._battery._text.set_markup('<small>%s</small>' % _("unknown"))
|
||||
panel._battery._text.set_markup('<small>%s</small>' % _('unknown'))
|
||||
else:
|
||||
charging = device.status.get(_K.BATTERY_CHARGING)
|
||||
icon_name = _icons.battery(battery_level, charging)
|
||||
|
@ -704,52 +704,52 @@ def _update_device_panel(device, panel, buttons, full=False):
|
|||
panel._battery._icon.set_sensitive(True)
|
||||
|
||||
if battery_voltage is not None:
|
||||
text = "%(battery_voltage)dmV" % {
|
||||
text = '%(battery_voltage)dmV' % {
|
||||
'battery_voltage': battery_voltage
|
||||
}
|
||||
elif isinstance(battery_level, _NamedInt):
|
||||
text = _(str(battery_level))
|
||||
else:
|
||||
text = "%(battery_percent)d%%" % {'battery_percent': battery_level}
|
||||
text = '%(battery_percent)d%%' % {'battery_percent': battery_level}
|
||||
if battery_next_level is not None:
|
||||
if isinstance(battery_next_level, _NamedInt):
|
||||
text += "<small> (" + _("next ") + _(
|
||||
str(battery_next_level)) + ")</small>"
|
||||
text += '<small> (' + _('next ') + _(
|
||||
str(battery_next_level)) + ')</small>'
|
||||
else:
|
||||
text += "<small> (" + _("next ") + (
|
||||
"%d%%" % battery_next_level) + ")</small>"
|
||||
text += '<small> (' + _('next ') + (
|
||||
'%d%%' % battery_next_level) + ')</small>'
|
||||
if is_online:
|
||||
if charging:
|
||||
text += ' <small>(%s)</small>' % _("charging")
|
||||
text += ' <small>(%s)</small>' % _('charging')
|
||||
else:
|
||||
text += ' <small>(%s)</small>' % _("last known")
|
||||
text += ' <small>(%s)</small>' % _('last known')
|
||||
panel._battery._text.set_sensitive(is_online)
|
||||
panel._battery._text.set_markup(text)
|
||||
|
||||
if is_online:
|
||||
not_secure = device.status.get(_K.LINK_ENCRYPTED) == False
|
||||
if not_secure:
|
||||
panel._secure._text.set_text(_("not encrypted"))
|
||||
panel._secure._text.set_text(_('not encrypted'))
|
||||
panel._secure._icon.set_from_icon_name('security-low',
|
||||
_INFO_ICON_SIZE)
|
||||
panel._secure.set_tooltip_text(
|
||||
_("The wireless link between this device and its receiver is not encrypted.\n"
|
||||
"\n"
|
||||
"For pointing devices (mice, trackballs, trackpads), this is a minor security issue.\n"
|
||||
"\n"
|
||||
"It is, however, a major security issue for text-input devices (keyboards, numpads),\n"
|
||||
"because typed text can be sniffed inconspicuously by 3rd parties within range."
|
||||
_('The wireless link between this device and its receiver is not encrypted.\n'
|
||||
'\n'
|
||||
'For pointing devices (mice, trackballs, trackpads), this is a minor security issue.\n'
|
||||
'\n'
|
||||
'It is, however, a major security issue for text-input devices (keyboards, numpads),\n'
|
||||
'because typed text can be sniffed inconspicuously by 3rd parties within range.'
|
||||
))
|
||||
else:
|
||||
panel._secure._text.set_text(_("encrypted"))
|
||||
panel._secure._text.set_text(_('encrypted'))
|
||||
panel._secure._icon.set_from_icon_name('security-high',
|
||||
_INFO_ICON_SIZE)
|
||||
panel._secure.set_tooltip_text(
|
||||
_("The wireless link between this device and its receiver is encrypted."
|
||||
_('The wireless link between this device and its receiver is encrypted.'
|
||||
))
|
||||
panel._secure._icon.set_visible(True)
|
||||
else:
|
||||
panel._secure._text.set_markup('<small>%s</small>' % _("offline"))
|
||||
panel._secure._text.set_markup('<small>%s</small>' % _('offline'))
|
||||
panel._secure._icon.set_visible(False)
|
||||
panel._secure.set_tooltip_text('')
|
||||
|
||||
|
@ -761,7 +761,7 @@ def _update_device_panel(device, panel, buttons, full=False):
|
|||
panel._lux._icon.set_from_icon_name(_icons.lux(light_level),
|
||||
_INFO_ICON_SIZE)
|
||||
panel._lux._text.set_text(
|
||||
_("%(light_level)d lux") % {'light_level': light_level})
|
||||
_('%(light_level)d lux') % {'light_level': light_level})
|
||||
panel._lux.set_visible(True)
|
||||
else:
|
||||
panel._lux.set_visible(False)
|
||||
|
@ -898,7 +898,7 @@ def update(device, need_popup=False):
|
|||
# peripheral
|
||||
is_paired = bool(device)
|
||||
assert device.receiver
|
||||
assert device.number is not None and device.number > 0, "invalid device number" + str(
|
||||
assert device.number is not None and device.number > 0, 'invalid device number' + str(
|
||||
device.number)
|
||||
item = _device_row(device.receiver.path, device.number,
|
||||
device if is_paired else None)
|
||||
|
@ -915,13 +915,13 @@ def update(device, need_popup=False):
|
|||
_model.set_value(item, _COLUMN.STATUS_ICON, _CAN_SET_ROW_NONE)
|
||||
else:
|
||||
if battery_voltage is not None:
|
||||
status_text = "%(battery_voltage)dmV" % {
|
||||
status_text = '%(battery_voltage)dmV' % {
|
||||
'battery_voltage': battery_voltage
|
||||
}
|
||||
elif isinstance(battery_level, _NamedInt):
|
||||
status_text = _(str(battery_level))
|
||||
else:
|
||||
status_text = "%(battery_percent)d%%" % {
|
||||
status_text = '%(battery_percent)d%%' % {
|
||||
'battery_percent': battery_level
|
||||
}
|
||||
_model.set_value(item, _COLUMN.STATUS_TEXT, status_text)
|
||||
|
|
|
@ -35,7 +35,7 @@ _suspend_callback = None
|
|||
def _suspend():
|
||||
if _suspend_callback:
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info("received suspend event")
|
||||
_log.info('received suspend event')
|
||||
_suspend_callback()
|
||||
|
||||
|
||||
|
@ -45,7 +45,7 @@ _resume_callback = None
|
|||
def _resume():
|
||||
if _resume_callback:
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info("received resume event")
|
||||
_log.info('received resume event')
|
||||
_resume_callback()
|
||||
|
||||
|
||||
|
@ -93,11 +93,11 @@ try:
|
|||
|
||||
if _log.isEnabledFor(_INFO):
|
||||
_log.info(
|
||||
"connected to system dbus, watching for suspend/resume events")
|
||||
'connected to system dbus, watching for suspend/resume events')
|
||||
|
||||
except:
|
||||
# Either:
|
||||
# - the dbus library is not available
|
||||
# - the system dbus is not running
|
||||
_log.warn("failed to register suspend/resume callbacks")
|
||||
_log.warn('failed to register suspend/resume callbacks')
|
||||
pass
|
||||
|
|
1
setup.py
1
setup.py
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from glob import glob as _glob
|
||||
|
||||
try:
|
||||
from setuptools import setup
|
||||
except ImportError:
|
||||
|
|
|
@ -13,7 +13,7 @@ sys.path += (sys.path[0] + '/../lib', )
|
|||
|
||||
|
||||
def print_event(action, device):
|
||||
print("~~~~ device [%s] %s" % (action, device))
|
||||
print('~~~~ device [%s] %s' % (action, device))
|
||||
|
||||
|
||||
hidapi.monitor(print_event, DEVICE_UNIFYING_RECEIVER,
|
||||
|
|
Loading…
Reference in New Issue