28
28
KEY_TYPE_OPENPGP = 'openpgp'
29
29
KEY_TYPE_SSH = 'ssh'
32
bus = dbus.SessionBus()
33
crypto = dbus.Interface(bus.get_object(BUS_NAME, CRYPTO_PATH),
35
openpgp = dbus.Interface(bus.get_object(BUS_NAME, OPENPGP_PATH),
37
except dbus.exceptions.DBusException, e:
38
get_name = getattr(e, 'get_dbus_name', None)
39
if get_name is not None:
42
name = getattr(e, '_dbus_error_name', None)
45
args = getattr(e, 'args', None) # This is case for old python-dbus-0.62
46
if args == ("Unable to determine the address of the message bus (try 'man dbus-launch' and 'man dbus-daemon' for help)",):
49
# DBus sometimes fails like this, just treat it as if seahorse is not
50
# available rather than crashing.
51
if name in ("org.freedesktop.DBus.Error.Spawn.ExecFailed",
52
"org.freedesktop.DBus.Error.ServiceUnknown",
53
"org.freedesktop.DBus.Error.NotSupported"):
31
bus = dbus.SessionBus()
33
if hasattr(bus, 'list_activatable_names'):
34
bus_names = bus.list_activatable_names()
36
bus_object = bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
37
bus_names = bus_object.ListNames(dbus_interface='org.freedesktop.DBus')
39
if BUS_NAME not in bus_names:
42
crypto = dbus.Interface(bus.get_object(BUS_NAME, CRYPTO_PATH),
44
openpgp = dbus.Interface(bus.get_object(BUS_NAME, OPENPGP_PATH),
58
47
FLAG_VALID = 0x0001
59
48
FLAG_CAN_ENCRYPT = 0x0002