[Checkins] SVN: zc.buildout/trunk/ Switched from using os.popen* to subprocess.Popen

Adam GROSZER agroszer at gmail.com
Mon Mar 23 05:18:45 EDT 2009


Hello Tres,

close_fds=True is not supported on win32.
The biggest problem is that after making it False on win32 still
breaks seemingly all doctests using system().
The output seemingly matches exactly the expected output, but the
tests burps on it.

e.g.:

File "f:\w\pyt\zope_fix\zc.buildout\src\zc\buildout\downloadcache.txt", line 61, in downloadcache.txt
Failed example:
    print system(buildout),
Expected:
    GET 200 /
    GET 200 /demo-0.2-pyN.N.egg
    GET 200 /demoneeded-1.2c1.zip
    Installing eggs.
    Getting distribution for 'demo==0.2'.
    Got demo 0.2.
    Getting distribution for 'demoneeded'.
    Got demoneeded 1.2c1.
    Generated script '/sample-buildout/bin/demo'.
Got:
    GET 200 /
    GET 200 /demo-0.2-pyN.N.egg
    GET 200 /demoneeded-1.2c1.zip
    Installing eggs.
    Getting distribution for 'demo==0.2'.
    Got demo 0.2.
    Getting distribution for 'demoneeded'.
    Got demoneeded 1.2c1.
    Generated script '/sample-buildout/bin/demo'.

Thursday, March 5, 2009, 5:39:07 AM, you wrote:

TS> Log message for revision 97510:
TS>   Switched from using os.popen* to subprocess.Popen
TS>   
TS>   o Avoids deprecation warnings in Python 2.6.  See:
TS>   
TS>    
TS> http://docs.python.org/library/subprocess.html#replacing-os-popen-os-popen2-os-popen3
TS>   

TS> Changed:
TS>   U   zc.buildout/trunk/CHANGES.txt
TS>   U   zc.buildout/trunk/src/zc/buildout/easy_install.py
TS>   U   zc.buildout/trunk/src/zc/buildout/testing.py


TS>  def system(command, input=''):
TS> -    i, o, e = os.popen3(command)
TS> +    p = subprocess.Popen(command,
TS> +                         shell=True,
TS> +                         stdin=subprocess.PIPE,
TS> +                         stdout=subprocess.PIPE,
TS> +                         stderr=subprocess.PIPE,
TS> +                         close_fds=True)
TS> +    i, o, e = (p.stdin, p.stdout, p.stderr)
TS>      if input:
TS>          i.write(input)
TS>      i.close()
TS> -    result = o.read()+e.read()
TS> +    result = o.read() + e.read()
TS>      o.close()
TS>      e.close()
TS>      return result

-- 
Best regards,
 Adam GROSZER                            mailto:agroszer at gmail.com
--
Quote of the day:
You are guileless in your dreams



More information about the Checkins mailing list