Initial Python 2.6 portability in SCons code itself, using subprocess
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 7 Oct 2008 00:40:11 +0000 (00:40 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 7 Oct 2008 00:40:11 +0000 (00:40 +0000)
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

src/engine/SCons/Platform/posix.py
src/engine/SCons/Tool/msvs.py
src/engine/SCons/Tool/rpm.py

index bc8d67c5028387795275082b0d3857c9b34857ae..12a6f60045a2f6d2cd5fcf26d838fcbe6ab6b663 100644 (file)
@@ -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
index 33efad9528789450e9f39a209d0b0cf29ffd8cdf..5aedf9c32016b35ad99e972767897045b71e02b4 100644 (file)
@@ -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
index 47759ea41b8593a712a31ce987c2dd7ea6e38089..adb9de1e1ae3ac8ba09e318107c86736e1816346 100644 (file)
@@ -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],