cli: handle NoSuchDevice exception when pinging device
This commit is contained in:
parent
ffd66e74c2
commit
eb6bacaed1
|
@ -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
|
||||
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue