level is returned as None in hidpp10.py when the performanceMX mouse is
charging. Since the battery state is unknown when beeing recharged it will now return "N/A". Before it would crash becasue level was None and could not be inserted using %d.
This commit is contained in:
parent
35830e3d50
commit
7a75813a84
|
@ -107,10 +107,13 @@ def _print_device(dev):
|
||||||
if battery is not None:
|
if battery is not None:
|
||||||
from logitech_receiver.common import NamedInt as _NamedInt
|
from logitech_receiver.common import NamedInt as _NamedInt
|
||||||
level, status = battery
|
level, status = battery
|
||||||
if isinstance(level, _NamedInt):
|
if level:
|
||||||
text = str(level)
|
if isinstance(level, _NamedInt):
|
||||||
|
text = str(level)
|
||||||
|
else:
|
||||||
|
text = '%d%%' % level
|
||||||
else:
|
else:
|
||||||
text = '%d%%' % level
|
text = 'N/A'
|
||||||
print (' Battery: %s, %s.' % (text, status))
|
print (' Battery: %s, %s.' % (text, status))
|
||||||
else:
|
else:
|
||||||
print (' Battery status unavailable.')
|
print (' Battery status unavailable.')
|
||||||
|
|
Loading…
Reference in New Issue