[PATCH] Get the DBus session bus address in a method
David Shea
dshea at redhat.com
Thu Mar 20 14:40:21 UTC 2014
It turns out that just getting the session address will try to launch
things that can fail.
---
pyanaconda/safe_dbus.py | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/pyanaconda/safe_dbus.py b/pyanaconda/safe_dbus.py
index e9ddfbb..e8e4c31 100644
--- a/pyanaconda/safe_dbus.py
+++ b/pyanaconda/safe_dbus.py
@@ -27,8 +27,11 @@ from pyanaconda.constants import DEFAULT_DBUS_TIMEOUT
DBUS_PROPS_IFACE = "org.freedesktop.DBus.Properties"
DBUS_SYSTEM_BUS_ADDR = Gio.dbus_address_get_for_bus_sync(Gio.BusType.SYSTEM,
None)
-DBUS_SESSION_BUS_ADDR = Gio.dbus_address_get_for_bus_sync(Gio.BusType.SESSION,
- None)
+
+# This one is a method instead of a constant because getting the address
+# for the session attempts to run dbus-launch and can fail
+def _get_dbus_session_bus_addr():
+ return Gio.dbus_address_get_for_bus_sync(Gio.BusType.SESSION, None)
class SafeDBusError(Exception):
"""Class for exceptions defined in this module."""
@@ -161,7 +164,7 @@ def dbus_get_session_connection():
try:
connection = Gio.DBusConnection.new_for_address_sync(
- DBUS_SESSION_BUS_ADDR,
+ _get_dbus_session_bus_addr(),
Gio.DBusConnectionFlags.AUTHENTICATION_CLIENT|
Gio.DBusConnectionFlags.MESSAGE_BUS_CONNECTION,
None, None)
--
1.9.0
More information about the anaconda-patches
mailing list