Skip to content

Commit f38fc51

Browse files
committed
Return none if device alias is not available
1 parent 236c8ed commit f38fc51

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

gatt/gatt_linux.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,16 @@ def alias(self):
351351
"""
352352
Returns the device's alias (name).
353353
"""
354-
return self._properties.Get('org.bluez.Device1', 'Alias')
354+
try:
355+
return self._properties.Get('org.bluez.Device1', 'Alias')
356+
except dbus.exceptions.DBusException as e:
357+
if e.get_dbus_name() == 'org.freedesktop.DBus.Error.UnknownObject':
358+
# BlueZ sometimes doesn't provide an alias, we then simply return `None`.
359+
# Might occur when device was deleted as the following issue points out:
360+
# https://github.com/blueman-project/blueman/issues/460
361+
return None
362+
else:
363+
raise _error_from_dbus_error(e)
355364

356365
def properties_changed(self, sender, changed_properties, invalidated_properties):
357366
"""

0 commit comments

Comments
 (0)