diff options
author | Sye van der Veen <svanderveen@blackberry.com> | 2014-01-24 17:56:30 (GMT) |
---|---|---|
committer | Sye van der Veen <svanderveen@blackberry.com> | 2014-01-24 17:56:30 (GMT) |
commit | 864b97c8e206ac024eb3307ceaea5a5844e89971 (patch) | |
tree | 59128bc2964318e5b96e0045e6bec3c30a9b08e8 | |
parent | 31f06d13a8c5f1bf8c3dc675088756e98172c61b (diff) | |
download | SCons-864b97c8e206ac024eb3307ceaea5a5844e89971.zip SCons-864b97c8e206ac024eb3307ceaea5a5844e89971.tar.gz SCons-864b97c8e206ac024eb3307ceaea5a5844e89971.tar.bz2 |
Fix TestCmd to use ctypes when PyWin32 is not installed, and respect os.environ.get('python_executable') in ActionTests
-rw-r--r-- | QMTest/TestCmd.py | 31 | ||||
-rw-r--r-- | src/engine/SCons/ActionTests.py | 5 |
2 files changed, 31 insertions, 5 deletions
diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 38e9cd3..b51d90f 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -672,8 +672,35 @@ except AttributeError: PIPE = subprocess.PIPE if subprocess.mswindows: - from win32file import ReadFile, WriteFile - from win32pipe import PeekNamedPipe + try: + from win32file import ReadFile, WriteFile + from win32pipe import PeekNamedPipe + except ImportError: + # If PyWin32 is not available, try ctypes instead + # XXX These replicate _just_enough_ PyWin32 behaviour for our purposes + import ctypes; from ctypes.wintypes import DWORD + def ReadFile(hFile, bufSize, ol=None): + assert ol is None + lpBuffer = ctypes.create_string_buffer(bufSize) + bytesRead = DWORD() + bErr = ctypes.windll.kernel32.ReadFile( + hFile, lpBuffer, bufSize, ctypes.byref(bytesRead), ol) + if not bErr: raise ctypes.WinError() + return (0, ctypes.string_at(lpBuffer, bytesRead.value)) + def WriteFile(hFile, data, ol=None): + assert ol is None + bytesWritten = DWORD() + bErr = ctypes.windll.kernel32.WriteFile( + hFile, data, len(data), ctypes.byref(bytesWritten), ol) + if not bErr: raise ctypes.WinError() + return (0, bytesWritten.value) + def PeekNamedPipe(hPipe, size): + assert size == 0 + bytesAvail = DWORD() + bErr = ctypes.windll.kernel32.PeekNamedPipe( + hPipe, None, size, None, ctypes.byref(bytesAvail), None) + if not bErr: raise ctypes.WinError() + return ("", bytesAvail.value, None) import msvcrt else: import select diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index 13c3b6c..3e900d7 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -185,9 +185,8 @@ class DummyNode(object): if os.name == 'java': python = os.path.join(sys.prefix, 'jython') else: - python = sys.executable - -_python_ = '"' + python + '"' + python = os.environ.get('python_executable', sys.executable) +_python_ = test.escape(python) _null = SCons.Action._null |