= Request - Entry #1 by Anonymous User on Apr 26, 2007 9:39 am
The testsuite in tests.py completes with errors on windows. Some of these are because context.py uses the pwd library to get the username. This is not present on a Windows box, applying the following patch attempts to use Mark Hammond's Win32 extensions to get the username.
Index: context.py
===================================================================
--- context.py (revision 261)
+++ context.py (revision 262)
@@ -1,9 +1,7 @@
import re
import os
-import pwd
import sys
import logging
-
import parser
import resolver
@@ -13,6 +11,27 @@
except ImportError:
platform = None
+
+# Get the username. Long-winded but platform-safe.
+try:
+ import pwd
+ username = pwd.getpwuid(os.getuid())[0]
+except ImportError:
+ pass
+
+try:
+ import win32api
+ username = win32api.GetUserName()
+except ImportError:
+ pass
+
+try:
+ username is None
+except NameError:
+ raise ImportError("Cannot import POSIX or win32 API to get username")
+
+
+
def select_one(filename, section_name):
sections = parser.parse(filename)
section = sections.get(section_name)
@@ -55,7 +74,7 @@
builtins = {
'cwd':os.path.abspath(os.getcwd()),
- 'username':pwd.getpwuid(os.getuid())[0],
+ 'username':username,
'buildoutdir':buildoutdir,
'platform':platform
}
|
|