Commit b81a29ab authored by tseaver's avatar tseaver

Switched from using os.popen* to subprocess.Popen

o Avoids deprecation warnings in Python 2.6.  See:

  http://docs.python.org/library/subprocess.html#replacing-os-popen-os-popen2-os-popen3


git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@97510 62d5b8a3-27da-0310-9561-8e5933582275
parent f1f1c0b8
...@@ -7,6 +7,11 @@ Change History ...@@ -7,6 +7,11 @@ Change History
1.1.2 (Unreleased) 1.1.2 (Unreleased)
================== ==================
- Switched from using os.popen* to subprocess.Popen, to avoid a deprecation
warning in Python 2.6. See:
http://docs.python.org/library/subprocess.html#replacing-os-popen-os-popen2-os-popen3
- Made sure the 'redo_pyc' function and the doctest checkers work with Python - Made sure the 'redo_pyc' function and the doctest checkers work with Python
executable paths containing spaces. executable paths containing spaces.
......
...@@ -31,6 +31,7 @@ import setuptools.archive_util ...@@ -31,6 +31,7 @@ import setuptools.archive_util
import setuptools.command.setopt import setuptools.command.setopt
import setuptools.package_index import setuptools.package_index
import shutil import shutil
import subprocess
import sys import sys
import tempfile import tempfile
import urlparse import urlparse
...@@ -78,7 +79,14 @@ def _get_version(executable): ...@@ -78,7 +79,14 @@ def _get_version(executable):
try: try:
return _versions[executable] return _versions[executable]
except KeyError: except KeyError:
i, o = os.popen4(_safe_arg(executable) + ' -V') cmd = _safe_arg(executable) + ' -V'
p = subprocess.Popen(cmd,
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
close_fds=True)
i, o = (p.stdin, p.stdout)
i.close() i.close()
version = o.read().strip() version = o.read().strip()
o.close() o.close()
......
...@@ -16,14 +16,24 @@ ...@@ -16,14 +16,24 @@
$Id$ $Id$
""" """
import BaseHTTPServer, os, random, re, shutil, socket, sys import BaseHTTPServer
import tempfile, threading, time, urllib2, errno import errno
import os
import pkg_resources import pkg_resources
import random
import re
import shutil
import socket
import subprocess
import sys
import tempfile
import threading
import time
import urllib2
import zc.buildout.buildout import zc.buildout.buildout
import zc.buildout.easy_install import zc.buildout.easy_install
from zc.buildout.rmtree import rmtree
from rmtree import rmtree
fsync = getattr(os, 'fsync', lambda fileno: None) fsync = getattr(os, 'fsync', lambda fileno: None)
...@@ -76,11 +86,17 @@ def write(dir, *args): ...@@ -76,11 +86,17 @@ def write(dir, *args):
def system(command, input=''): def system(command, input=''):
i, o, e = os.popen3(command) p = subprocess.Popen(command,
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=True)
i, o, e = (p.stdin, p.stdout, p.stderr)
if input: if input:
i.write(input) i.write(input)
i.close() i.close()
result = o.read()+e.read() result = o.read() + e.read()
o.close() o.close()
e.close() e.close()
return result return result
...@@ -122,21 +138,39 @@ def find_python(version): ...@@ -122,21 +138,39 @@ def find_python(version):
if os.path.exists(e): if os.path.exists(e):
return e return e
else: else:
i, o = os.popen4('python%s -c "import sys; print sys.executable"' cmd = 'python%s -c "import sys; print sys.executable"' % version
% version) p = subprocess.Popen(cmd,
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
close_fds=True)
i, o = (p.stdin, p.stdout)
i.close() i.close()
e = o.read().strip() e = o.read().strip()
o.close() o.close()
if os.path.exists(e): if os.path.exists(e):
return e return e
i, o = os.popen4( cmd = 'python -c "import sys; print \'%s.%s\' % sys.version_info[:2]"'
'python -c "import sys; print \'%s.%s\' % sys.version_info[:2]"' p = subprocess.Popen(cmd,
) shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
close_fds=True)
i, o = (p.stdin, p.stdout)
i.close() i.close()
e = o.read().strip() e = o.read().strip()
o.close() o.close()
if e == version: if e == version:
i, o = os.popen4('python -c "import sys; print sys.executable"') cmd = 'python -c "import sys; print sys.executable"'
p = subprocess.Popen(cmd,
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
close_fds=True)
i, o = (p.stdin, p.stdout)
i.close() i.close()
e = o.read().strip() e = o.read().strip()
o.close() o.close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment