From f15cefbc1e1cef5f3085aa0cce55aece7bece8f1 Mon Sep 17 00:00:00 2001 From: Christopher Schramm Date: Fri, 15 May 2015 08:35:44 +0200 Subject: [PATCH] Catch exception when loading services Adding a service may fail e.g. due to the corresponding dbus interface not being available when querying the state. Previously that led to all (following) services not being available in the menu. We now catch and print an exception and go on adding more services, so that only the failing items themselves will be missing. --- blueman/plugins/manager/Services.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/blueman/plugins/manager/Services.py b/blueman/plugins/manager/Services.py index fbc757f26..9442e0e12 100644 --- a/blueman/plugins/manager/Services.py +++ b/blueman/plugins/manager/Services.py @@ -6,8 +6,8 @@ from blueman.bluez.Network import Network from blueman.plugins.ManagerPlugin import ManagerPlugin from gi.repository import Gtk - -from blueman.Functions import create_menuitem, get_icon, composite_icon +import traceback +from blueman.Functions import create_menuitem, get_icon, composite_icon, dprint from blueman.main.AppletService import AppletService from blueman.services import * @@ -56,7 +56,12 @@ def add_menu_item(manager_menu, service): if isinstance(service, Input): manager_menu.Signals.Handle("bluez", device, manager_menu.service_property_changed, "PropertyChanged") - add_menu_item(manager_menu, service) + try: + add_menu_item(manager_menu, service) + except Exception as e: + dprint("Failed to load service %s" % service.name) + traceback.print_exc() + continue if service.group == 'serial': for dev in rfcomm_list():