Created by: viniciusbm
The implementation of dynamic features causes some exceptions when we click the name of an idle device. An example:
Traceback (most recent call last):
File "…/Solaar/lib/solaar/ui/window.py", line 395, in _device_selected
_update_info_panel(device, full=True)
File "…/Solaar/lib/solaar/ui/window.py", line 759, in _update_info_panel
_update_device_panel(device, _info._device, _info._buttons, full)
File "…/Solaar/lib/solaar/ui/window.py", line 730, in _update_device_panel
_config_panel.update(device, is_online)
File "…/Solaar/lib/solaar/ui/config_panel.py", line 292, in update
for s in device.settings:
File "…/Solaar/lib/logitech_receiver/receiver.py", line 275, in settings
self._settings = [s(self) for s in self.descriptor.settings]
File "…/Solaar/lib/logitech_receiver/receiver.py", line 275, in <listcomp>
self._settings = [s(self) for s in self.descriptor.settings]
File "…/Solaar/lib/logitech_receiver/settings_templates.py", line 178, in instantiate
choices = choices_callback(device)
File "…/Solaar/lib/logitech_receiver/settings_templates.py", line 532, in _feature_reprogrammable_keys_choices
assert count, 'Oops, reprogrammable key count cannot be retrieved!'
AssertionError: Oops, reprogrammable key count cannot be retrieved!
Solaar still works as expected and no errors are shown if we do that when the device is online, so this is not a big problem. I think it's worth fixing it anyway, especially because those meaningless error messages may be confusing to users and can make it harder to debug real problems.
This change catches the exceptions and raises them again only if the device is online. I'm not sure if this is the best approach, so ideas are welcome.