[Greater-commits] r249 - trunk/GREAT-ER-DB/impl/postgresql/test

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Jun 22 17:51:17 CEST 2011


Author: aheinecke
Date: 2011-06-22 17:51:17 +0200 (Wed, 22 Jun 2011)
New Revision: 249

Modified:
   trunk/GREAT-ER-DB/impl/postgresql/test/postgressupport.py
Log:
Replace popenX usage with subprocess Popen


Modified: trunk/GREAT-ER-DB/impl/postgresql/test/postgressupport.py
===================================================================
--- trunk/GREAT-ER-DB/impl/postgresql/test/postgressupport.py	2011-06-22 15:38:20 UTC (rev 248)
+++ trunk/GREAT-ER-DB/impl/postgresql/test/postgressupport.py	2011-06-22 15:51:17 UTC (rev 249)
@@ -14,7 +14,7 @@
 import sys
 import os
 import time
-import popen2
+from subprocess import Popen, PIPE
 import shutil
 import traceback
 
@@ -31,7 +31,7 @@
 
 def run_config_script(cmdline):
     """Run command cmdline and return its stdout or none in case of errors"""
-    pipe = os.popen(cmdline)
+    pipe = Popen(cmdline, shell=True, stdout=PIPE).stdout
     result = pipe.read()
     if pipe.close() is not None:
         raise RuntimeError('Command %r failed' % cmdline)
@@ -47,9 +47,9 @@
     If outfilename is None stdout and stderr are still captured but they
     are ignored and not written to any file.
     """
-    proc = popen2.Popen4(command)
-    proc.tochild.close()
-    output = proc.fromchild.read()
+    proc = Popen(command, shell=True,
+                 stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
+    output = proc.stdout.read() + proc.stderr.read()
     status = proc.wait()
     if outfilename is not None:
         outfile = open(outfilename, "w")



More information about the Greater-commits mailing list