[Checkins] SVN: lovely.recipe/trunk/src/lovely/recipe/fs/ win32 does not have pwd module
Adam Groszer
agroszer at gmail.com
Mon May 18 05:20:36 EDT 2009
Log message for revision 100063:
win32 does not have pwd module
Changed:
U lovely.recipe/trunk/src/lovely/recipe/fs/mkdir.py
U lovely.recipe/trunk/src/lovely/recipe/fs/tests.py
-=-
Modified: lovely.recipe/trunk/src/lovely/recipe/fs/mkdir.py
===================================================================
--- lovely.recipe/trunk/src/lovely/recipe/fs/mkdir.py 2009-05-18 08:20:01 UTC (rev 100062)
+++ lovely.recipe/trunk/src/lovely/recipe/fs/mkdir.py 2009-05-18 09:20:36 UTC (rev 100063)
@@ -1,6 +1,13 @@
import logging
import os
-import pwd
+import sys
+
+is_win32 = sys.platform == 'win32'
+
+if not is_win32:
+ import pwd
+ #win32 does not have pwd
+
import zc.buildout
@@ -12,16 +19,19 @@
self.options = options
owner = options.get('owner')
if owner:
- try:
- uid = pwd.getpwnam(owner)[2]
- except KeyError:
- raise zc.buildout.UserError(
- 'The user %s does not exist.' % owner)
- if os.getuid() != 0:
- raise zc.buildout.UserError(
- 'Only root can change the owner to %s.' % owner)
+ if is_win32:
+ logging.getLogger(self.name).info( 'Cannot set owner on win32!')
+ else:
+ try:
+ uid = pwd.getpwnam(owner)[2]
+ except KeyError:
+ raise zc.buildout.UserError(
+ 'The user %s does not exist.' % owner)
+ if os.getuid() != 0:
+ raise zc.buildout.UserError(
+ 'Only root can change the owner to %s.' % owner)
- options['owner-uid'] = str(uid)
+ options['owner-uid'] = str(uid)
self.createPath = options.get('createpath', 'False').lower() in [
'true', 'on', '1']
@@ -50,4 +60,3 @@
uid = int(uid)
os.chown(path, uid, -1)
return ()
-
Modified: lovely.recipe/trunk/src/lovely/recipe/fs/tests.py
===================================================================
--- lovely.recipe/trunk/src/lovely/recipe/fs/tests.py 2009-05-18 08:20:01 UTC (rev 100062)
+++ lovely.recipe/trunk/src/lovely/recipe/fs/tests.py 2009-05-18 09:20:36 UTC (rev 100063)
@@ -17,6 +17,7 @@
__docformat__ = 'restructuredtext'
import os
+import sys
from zc.buildout import testing
import doctest, unittest
@@ -24,11 +25,12 @@
from lovely.recipe.testing import setUpBuildout
+is_win32 = sys.platform == 'win32'
def test_suite():
test_file = 'README.txt'
- if os.getuid() == 0:
+ if not is_win32 and os.getuid() == 0:
test_file = 'mkdir-root.txt'
return unittest.TestSuite((
@@ -42,4 +44,3 @@
testing.normalize_script,
testing.normalize_egg_py])
)))
-
More information about the Checkins
mailing list