From 982c11215578b75d6761296e36a3d6d7f32b4c6e Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 13 Apr 2007 17:46:07 +0000 Subject: Make debugging tp-gabble easier When the environment variable TP_DEBUG is set, the sugar shell will print out the session bus address it's using, then poll that bus every 5 seconds waiting for a gabble instance to appear. This allows you to launch gabble in another window for debugging with LM_DEBUG and gdb, which wasn't possible before because the sugar emulator uses a custom session bus. --- (limited to 'shell') diff --git a/shell/sugar-shell b/shell/sugar-shell index f0cda4d..c203298 100755 --- a/shell/sugar-shell +++ b/shell/sugar-shell @@ -81,6 +81,39 @@ if not key or not len(key): gtk.main() profile.update() +def check_gabble(bus_name): + try: + import dbus + bus = dbus.SessionBus() + bus_object = bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus') + name = bus_object.GetNameOwner(bus_name, dbus_interface='org.freedesktop.DBus') + if name: + return True + except dbus.DBusException: + pass + return False + +if os.environ.has_key("TP_DEBUG"): + # Allow the user time to start up telepathy connection managers + # using the Sugar DBus bus address + import time + from telepathy.client import ManagerRegistry + + registry = ManagerRegistry() + registry.LoadManagers() + try: + gabble = registry.services["gabble"] + except KeyError: + raise RuntimeError("Gabble connection manager not found!") + + while not check_gabble(gabble['busname']): + print "Waiting for gabble on: DBUS_SESSION_BUS_ADDRESS=%s" % os.environ["DBUS_SESSION_BUS_ADDRESS"] + try: + time.sleep(5) + except KeyboardInterrupt: + print "Got Ctrl+C, continuing..." + break + model = ShellModel() service = ShellService(model) shell = Shell(model) -- cgit v0.9.1