diff options
author | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2012-08-30 11:13:54 +0200 |
---|---|---|
committer | Sjoerd Simons <sjoerd@luon.net> | 2012-08-30 11:13:54 +0200 |
commit | 587bd3045cfae8f1ecf7c357a732b4f78df98459 (patch) | |
tree | 47105bc20ab88fe513118c41daa0d70780d85d84 | |
parent | 6baa10139a187183b75e6f7a731c2287c6609405 (diff) |
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
-rw-r--r-- | src/util.py | 19 |
1 files changed, 19 insertions, 0 deletions
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 |