From: stevenknight Date: Tue, 7 Oct 2008 00:40:11 +0000 (+0000) Subject: Initial Python 2.6 portability in SCons code itself, using subprocess X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=547a4cf69af42a299ae3c59a020a0e9470b898f3;p=scons.git Initial Python 2.6 portability in SCons code itself, using subprocess in place of popen2, and calling hashlib.md5() instead of the md5 module. git-svn-id: http://scons.tigris.org/svn/scons/trunk@3571 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/engine/SCons/Platform/posix.py b/src/engine/SCons/Platform/posix.py index bc8d67c5..12a6f600 100644 --- a/src/engine/SCons/Platform/posix.py +++ b/src/engine/SCons/Platform/posix.py @@ -35,8 +35,8 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import errno import os import os.path -import popen2 import string +import subprocess import sys import select @@ -131,8 +131,10 @@ def process_cmd_output(cmd_stdout, cmd_stderr, stdout, stderr): raise def exec_popen3(l, env, stdout, stderr): - proc = popen2.Popen3(string.join(l), 1) - process_cmd_output(proc.fromchild, proc.childerr, stdout, stderr) + proc = subprocess.Popen(string.join(l), + stdout=stdout, + stderr=stderr, + shell=True) stat = proc.wait() if stat & 0xff: return stat | 0x80 diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index 33efad95..5aedf9c3 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -34,7 +34,7 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import base64 -import md5 +import hashlib import os.path import pickle import re @@ -79,9 +79,11 @@ def _generateGUID(slnfile, name): based on the MD5 signatures of the sln filename plus the name of the project. It basically just needs to be unique, and not change with each invocation.""" + m = hashlib.md5() + m.update(str(slnfile) + str(name)) # TODO(1.5) - #solution = _hexdigest(md5.new(str(slnfile)+str(name)).digest()).upper() - solution = string.upper(_hexdigest(md5.new(str(slnfile)+str(name)).digest())) + #solution = m.hexdigest().upper() + solution = string.upper(_hexdigest(m.digest())) # convert most of the signature to GUID form (discard the rest) solution = "{" + solution[:8] + "-" + solution[8:12] + "-" + solution[12:16] + "-" + solution[16:20] + "-" + solution[20:32] + "}" return solution diff --git a/src/engine/SCons/Tool/rpm.py b/src/engine/SCons/Tool/rpm.py index 47759ea4..adb9de1e 100644 --- a/src/engine/SCons/Tool/rpm.py +++ b/src/engine/SCons/Tool/rpm.py @@ -38,7 +38,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os import re import shutil -import popen2 +import subprocess import SCons.Builder import SCons.Node.FS @@ -67,11 +67,12 @@ def build_rpm(target, source, env): env.Prepend( RPMFLAGS = '--define \'_topdir %s\'' % tmpdir ) # now call rpmbuild to create the rpm package. - handle = popen2.Popen3( get_cmd(source, env), capturestderr=1 ) - output = handle.fromchild.read() - #output += handle.childerr.read() - output = output + handle.childerr.read() - status = handle.wait() + handle = subprocess.Popen(get_cmd(source, env), + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + shell=True) + output = handle.stdout.read() + status = handle.wait() if status: raise SCons.Errors.BuildError( node=target[0],