[conduit: 127/138] Capture dbus-monitor output properly in a tempfile.TemporaryFile (this will be clean up magically wh



commit c71c31a9d3ff65e96614814c7182ab9c8d8058fa
Author: John Carr <john carr unrouted co uk>
Date:   Wed May 6 15:14:17 2009 -0700

    Capture dbus-monitor output properly in a tempfile.TemporaryFile (this will be clean up magically when its gc'd)
---
 test/soup/env/fake-dbus.py |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/test/soup/env/fake-dbus.py b/test/soup/env/fake-dbus.py
index 2206ee2..eb9e72b 100644
--- a/test/soup/env/fake-dbus.py
+++ b/test/soup/env/fake-dbus.py
@@ -41,14 +41,13 @@ class Dbus(soup.env.EnvironmentWrapper):
 
     def decorate_test(self, test):
         def _(*args, **kwargs):
-            fd, f = tempfile.mkstemp()
-            os.close(fd)
-            p = subprocess.Popen("dbus-monitor &> %s" % f, shell=True)
+            logfile = tempfile.TemporaryFile()
+            p = subprocess.Popen("dbus-monitor", stdout=logfile, stderr=subprocess.STDOUT, close_fds=True)
             test(*args, **kwargs)
             os.kill(p.pid, signal.SIGINT)
+            logfile.seek(0)
             # FIXME: Need some way to attach data to a test
             # print open(f).read()
-            os.unlink(f)
         return _
 
     def finalize_environment(self):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]