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:
David Plassmann 2013-09-24 16:56:50 +02:00
parent 35830e3d50
commit 7a75813a84
1 changed files with 6 additions and 3 deletions

View File

@ -107,10 +107,13 @@ def _print_device(dev):
if battery is not None:
from logitech_receiver.common import NamedInt as _NamedInt
level, status = battery
if isinstance(level, _NamedInt):
text = str(level)
if level:
if isinstance(level, _NamedInt):
text = str(level)
else:
text = '%d%%' % level
else:
text = '%d%%' % level
text = 'N/A'
print (' Battery: %s, %s.' % (text, status))
else:
print (' Battery status unavailable.')