From 587bd3045cfae8f1ecf7c357a732b4f78df98459 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Thu, 30 Aug 2012 11:13:54 +0200 Subject: Watch the stdout of the dbus daemon When application launch by dbus spew to their standout they can get blocked if stdout is a pipe that's not actually read.. Also this allows debugging of subprocesses to come through --- src/util.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/util.py b/src/util.py index 146d450..ae8ac59 100644 --- a/src/util.py +++ b/src/util.py @@ -3,9 +3,26 @@ import subprocess import atexit import os +import sys import signal import dbus +from threading import Thread +from gi.repository import GLib, Gio +from gi.repository import TelepathyGLib as Tp + + +def _got_line (d, r, u): + line = d.read_line_finish (r) + print "STDOUT: " + str(line) + d.read_line_async (0, None, _got_line, None) + +def _process_input(f): + i = Gio.UnixInputStream.new (f.fileno(), True) + d = Gio.DataInputStream.new (i) + d.read_line_async (0, None, _got_line, None) + + def spawnbus(config = None): command = [ "dbus-daemon", "--session", "--nofork", "--print-address" ] if config: @@ -20,6 +37,8 @@ def spawnbus(config = None): os.environ ["DBUS_SESSION_BUS_ADDRESS"] = address print "Temporary Session bus: %s" % address + # Process stdout + _process_input (process.stdout) def override_env (variable, var): os.environ[variable] = var -- cgit v1.2.3