From 7a75813a844b97de192300f6645a486be618695e Mon Sep 17 00:00:00 2001 From: David Plassmann Date: Tue, 24 Sep 2013 16:56:50 +0200 Subject: [PATCH 1/2] 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. --- lib/solaar/cli/show.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/solaar/cli/show.py b/lib/solaar/cli/show.py index 52d723a5..b7104143 100644 --- a/lib/solaar/cli/show.py +++ b/lib/solaar/cli/show.py @@ -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.') From 8485494ea75c7196b620609dc71b86e268b3aaa2 Mon Sep 17 00:00:00 2001 From: David Plassmann Date: Wed, 25 Sep 2013 14:12:53 +0200 Subject: [PATCH 2/2] It should check for None specificly --- lib/solaar/cli/show.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solaar/cli/show.py b/lib/solaar/cli/show.py index b7104143..29f7ca62 100644 --- a/lib/solaar/cli/show.py +++ b/lib/solaar/cli/show.py @@ -107,7 +107,7 @@ def _print_device(dev): if battery is not None: from logitech_receiver.common import NamedInt as _NamedInt level, status = battery - if level: + if level is not None: if isinstance(level, _NamedInt): text = str(level) else: