32
32
    bus = dbus.SessionBus()
 
33
33
except dbus.exceptions.DBusException, e:
 
34
 
    get_name = getattr(e, 'get_dbus_name', None)
 
35
 
    if get_name is not None:
 
38
 
        name = getattr(e, '_dbus_error_name', None)
 
39
 
    # DBus sometimes fails like this, just treat it as if seahorse is not
 
40
 
    # available rather than crashing.
 
41
 
    if name == "org.freedesktop.DBus.Error.Spawn.ExecFailed":
 
 
37
    crypto = dbus.Interface(bus.get_object(BUS_NAME, CRYPTO_PATH), 
 
 
39
    openpgp = dbus.Interface(bus.get_object(BUS_NAME, OPENPGP_PATH),
 
 
41
except dbus.exceptions.DBusException, e:
 
 
42
    if e.get_dbus_name() == 'org.freedesktop.DBus.Error.ServiceUnknown':
 
46
 
if hasattr(bus, 'list_activatable_names'):
 
47
 
    bus_names = bus.list_activatable_names()
 
49
 
    bus_object = bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
 
50
 
    bus_names = bus_object.ListNames(dbus_interface='org.freedesktop.DBus')
 
52
 
if BUS_NAME not in bus_names:
 
55
 
crypto = dbus.Interface(bus.get_object(BUS_NAME, CRYPTO_PATH), 
 
57
 
openpgp = dbus.Interface(bus.get_object(BUS_NAME, OPENPGP_PATH),
 
60
46
FLAG_VALID = 0x0001
 
61
47
FLAG_CAN_ENCRYPT = 0x0002