[py-svn] r61954 - in py/trunk/py: bin execnet misc process

getxsick at codespeak.net getxsick at codespeak.net
Mon Feb 16 20:30:16 CET 2009


Author: getxsick
Date: Mon Feb 16 20:30:14 2009
New Revision: 61954

Modified:
   py/trunk/py/bin/gendoc.py
   py/trunk/py/execnet/register.py
   py/trunk/py/misc/_dist.py
   py/trunk/py/process/cmdexec.py
Log:
removed of using some deprecated modules/functions from stdlib.
used subprocess instead (the module is included to stdlib since 2.4)


Modified: py/trunk/py/bin/gendoc.py
==============================================================================
--- py/trunk/py/bin/gendoc.py	(original)
+++ py/trunk/py/bin/gendoc.py	Mon Feb 16 20:30:14 2009
@@ -15,11 +15,12 @@
 sys.path.insert(0, '.')
 
 import py
-import os
+import os, subprocess
 
 def sysexec(cmd):
     print "executing", cmd
-    os.system(cmd)
+    p = subprocess.Popen(cmd, shell=True)
+    os.waitpid(p.pid, 0)
 
 if __name__ == '__main__':
     pydir = py.path.local().join("py")

Modified: py/trunk/py/execnet/register.py
==============================================================================
--- py/trunk/py/execnet/register.py	(original)
+++ py/trunk/py/execnet/register.py	Mon Feb 16 20:30:14 2009
@@ -1,5 +1,6 @@
 
 import os, inspect, socket
+from subprocess import Popen, PIPE
 import sys
 from py.magic import autopath ; mypath = autopath()
 from py.__.misc.warn import APIWARN
@@ -56,7 +57,8 @@
 
 class PopenCmdGateway(InstallableGateway):
     def __init__(self, cmd):
-        infile, outfile = os.popen2(cmd)
+        p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, close_fds=True)
+        infile, outfile = p.stdin, p.stdout
         self._cmd = cmd
         io = inputoutput.Popen2IO(infile, outfile)
         super(PopenCmdGateway, self).__init__(io=io)

Modified: py/trunk/py/misc/_dist.py
==============================================================================
--- py/trunk/py/misc/_dist.py	(original)
+++ py/trunk/py/misc/_dist.py	Mon Feb 16 20:30:14 2009
@@ -1,5 +1,6 @@
 import py
 import sys, os, re
+import subprocess
 from distutils import sysconfig
 from distutils import core 
 
@@ -147,7 +148,8 @@
         win32con.SMTO_ABORTIFHUNG, 5000)
 
     # Propagate changes to current command prompt
-    os.system("set PATH=%s" % path)
+    p = subprocess.Popen("set PATH=%s" % path, shell=True)
+    os.waitpid(p.pid, 0)
     
 def get_registry_value(reg, key, value_name):
     k = _winreg.OpenKey(reg, key)

Modified: py/trunk/py/process/cmdexec.py
==============================================================================
--- py/trunk/py/process/cmdexec.py	(original)
+++ py/trunk/py/process/cmdexec.py	Mon Feb 16 20:30:14 2009
@@ -24,13 +24,13 @@
     the error-output from the command.
     """
     __tracebackhide__ = True
-    import popen2
+    from subprocess import Popen, PIPE
     import errno
 
     #print "execing", cmd
-    child = popen2.Popen3(cmd, 1)
-    stdin, stdout, stderr = child.tochild, child.fromchild, child.childerr
-    stdin.close()
+    child = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE,
+                                                                close_fds=True)
+    stdin, stdout, stderr = child.stdin, child.stdout, child.stderr
 
     # XXX sometimes we get a blocked r.read() call (see below)
     #     although select told us there is something to read.



More information about the pytest-commit mailing list