device: catch errors when pinging to try to put device online

This commit is contained in:
Peter F. Patel-Schneider 2023-11-18 19:06:39 -05:00
parent 4669cad2e1
commit b2eb039e2d
1 changed files with 4 additions and 1 deletions

View File

@ -195,7 +195,10 @@ class Device:
def name(self):
if not self._name:
if not self.online: # be very defensive
try:
self.ping()
except _base.NoSuchDevice:
pass
if self.online and self.protocol >= 2.0:
self._name = _hidpp20.get_name(self)
return self._name or self._codename or ('Unknown device %s' % (self.wpid or self.product_id))