Skip to content

Commit

Permalink
cli: handle NoSuchDevice exception when pinging device
Browse files Browse the repository at this point in the history
  • Loading branch information
pfps committed Nov 18, 2023
1 parent ffd66e7 commit a7d2e99
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/solaar/cli/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
## with this program; if not, write to the Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

from logitech_receiver import base as _base
from logitech_receiver import hidpp10 as _hidpp10
from logitech_receiver import hidpp20 as _hidpp20
from logitech_receiver import receiver as _receiver
Expand Down Expand Up @@ -81,8 +82,12 @@ def _battery_line(dev):

def _print_device(dev, num=None):
assert dev is not None
# check if the device is online
dev.ping()
# try to ping the device to see if it actually exists and to wake it up
try:
dev.ping()
except _base.NoSuchDevice:
print(' %d: Device not found' % num or dev.number)
return

print(' %d: %s' % (num or dev.number, dev.name))
print(' Device path :', dev.path)
Expand Down

0 comments on commit a7d2e99

Please sign in to comment.