From e3c10abea18f62b8b4bb2990428739c28054390b Mon Sep 17 00:00:00 2001
From: Nicolas Dumazet <nicolas.dumazet@nexedi.com>
Date: Tue, 13 Oct 2009 14:38:17 +0000
Subject: [PATCH] test runner: use subprocess instead of os.popen

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29605 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Tool/TemplateTool.py | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/product/ERP5/Tool/TemplateTool.py b/product/ERP5/Tool/TemplateTool.py
index 88d68f96d6..106260838c 100644
--- a/product/ERP5/Tool/TemplateTool.py
+++ b/product/ERP5/Tool/TemplateTool.py
@@ -52,6 +52,7 @@ from base64 import b64encode, b64decode
 from Products.ERP5Type.Message import translateString
 from zLOG import LOG, INFO
 from base64 import decodestring
+import subprocess
 
 
 WIN = os.name == 'nt'
@@ -452,16 +453,17 @@ class TemplateTool (BaseTool):
         outfile =  StringIO()
       if RESPONSE is not None:
         RESPONSE.setHeader('Content-type', 'text/plain')
-      process = os.popen('%s %s %s 2>&1'
-                      % (sys.executable,
-                         getUnitTestFile(),
-                         ' '.join(test_list)))
-      while 1:
-        try:
-          outfile.write(process.next())
-          outfile.flush()
-        except StopIteration:
-          break
+      test_cmd_args = [sys.executable, getUnitTestFile()]
+      test_cmd_args += test_list
+      process = subprocess.Popen(test_cmd_args,
+                                 stdout=subprocess.PIPE,
+                                 stderr=subprocess.STDOUT)
+
+      output = process.communicate()[0]
+
+      outfile.write(output)
+      outfile.flush()
+
       if hasattr(outfile, 'getvalue'):
         return outfile.getvalue()
 
-- 
2.30.9