[Checkins] SVN: zc.buildout/trunk/src/zc/buildout/ Restore compatibility to Windows XP and Python2.4.
Sebastian Wehrmann
sw at gocept.com
Thu Aug 13 07:12:32 EDT 2009
Log message for revision 102733:
Restore compatibility to Windows XP and Python2.4.
Changed:
U zc.buildout/trunk/src/zc/buildout/buildout.py
U zc.buildout/trunk/src/zc/buildout/download.py
U zc.buildout/trunk/src/zc/buildout/download.txt
U zc.buildout/trunk/src/zc/buildout/tests.py
-=-
Modified: zc.buildout/trunk/src/zc/buildout/buildout.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/buildout.py 2009-08-13 11:04:08 UTC (rev 102732)
+++ zc.buildout/trunk/src/zc/buildout/buildout.py 2009-08-13 11:12:32 UTC (rev 102733)
@@ -1262,7 +1262,8 @@
if filename in seen:
if is_temp:
- os.unlink(path)
+ fp.close()
+ os.remove(path)
raise zc.buildout.UserError("Recursive file include", seen, filename)
root_config_file = not seen
@@ -1274,7 +1275,8 @@
parser.optionxform = lambda s: s
parser.readfp(fp)
if is_temp:
- os.unlink(path)
+ fp.close()
+ os.remove(path)
extends = extended_by = None
for section in parser.sections():
Modified: zc.buildout/trunk/src/zc/buildout/download.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/download.py 2009-08-13 11:04:08 UTC (rev 102732)
+++ zc.buildout/trunk/src/zc/buildout/download.py 2009-08-13 11:12:32 UTC (rev 102733)
@@ -21,6 +21,7 @@
import logging
import os
import os.path
+import re
import shutil
import tempfile
import urllib
@@ -148,6 +149,8 @@
returned and the client code is responsible for cleaning it up.
"""
+ if re.match(r"^[A-Za-z]:\\", url):
+ url = 'file:' + url
parsed_url = urlparse.urlparse(url, 'file')
url_scheme, _, url_path = parsed_url[:3]
if url_scheme == 'file':
@@ -171,11 +174,11 @@
if not check_md5sum(tmp_path, md5sum):
raise ChecksumError(
'MD5 checksum mismatch downloading %r' % url)
- except:
- os.remove(tmp_path)
- raise
- finally:
- os.close(handle)
+ finally:
+ os.close(handle)
+ except:
+ os.remove(tmp_path)
+ raise
if path:
shutil.move(tmp_path, path)
@@ -190,16 +193,27 @@
if self.hash_name:
return md5(url).hexdigest()
else:
- parsed = urlparse.urlparse(url)
+ if re.match(r"^[A-Za-z]:\\", url):
+ url = 'file:' + url
+ parsed = urlparse.urlparse(url, 'file')
url_path = parsed[2]
- for name in reversed(url_path.split('/')):
- if name:
- return name
+
+ if parsed[0] == 'file':
+ while True:
+ url_path, name = os.path.split(url_path)
+ if name:
+ return name
+ if not url_path:
+ break
else:
- url_host, url_port = parsed[-2:]
- return '%s:%s' % (url_host, url_port)
+ for name in reversed(url_path.split('/')):
+ if name:
+ return name
+ url_host, url_port = parsed[-2:]
+ return '%s:%s' % (url_host, url_port)
+
def check_md5sum(path, md5sum):
"""Tell whether the MD5 checksum of the file at path matches.
Modified: zc.buildout/trunk/src/zc/buildout/download.txt
===================================================================
--- zc.buildout/trunk/src/zc/buildout/download.txt 2009-08-13 11:04:08 UTC (rev 102732)
+++ zc.buildout/trunk/src/zc/buildout/download.txt 2009-08-13 11:12:32 UTC (rev 102733)
@@ -121,7 +121,7 @@
>>> cat(download(join(server_data, 'foo.txt'))[0])
This is a foo text.
->>> cat(download('file://%s/foo.txt' % server_data)[0])
+>>> cat(download('file:' + join(server_data, 'foo.txt'))[0])
This is a foo text.
>>> remove(path)
@@ -231,7 +231,7 @@
>>> write(server_data, 'foo.txt', 'This is a foo text.')
>>> download = Download(cache=cache)
->>> cat(download('file://' + join(server_data, 'foo.txt'), path=path)[0])
+>>> cat(download('file:' + join(server_data, 'foo.txt'), path=path)[0])
This is a foo text.
>>> ls(cache)
- foo.txt
@@ -260,7 +260,7 @@
>>> Download(cache=join(cache, 'non-existent'))(server_url+'foo.txt')
Traceback (most recent call last):
UserError: The directory:
-'/tmp/tmpZ2cwCfbuildoutSetUp/_TEST_/download-cache/non-existent'
+'/download-cache/non-existent'
to be used as a download cache doesn't exist.
Using namespace sub-directories of the download cache
@@ -337,7 +337,7 @@
the test is run, so we don't actually know the full URL of the file. Let's
check that the checksum actually belongs to the particular URL used:
->>> path == join(cache, md5(server_url+'foo.txt').hexdigest())
+>>> path.lower() == join(cache, md5(server_url+'foo.txt').hexdigest()).lower()
True
The cached copy is used when downloading the file again:
@@ -359,7 +359,7 @@
/download-cache/537b6d73267f8f4447586989af8c470e
>>> path == path2
False
->>> path2 == join(cache, md5(server_url+'other/foo.txt').hexdigest())
+>>> path2.lower() == join(cache, md5(server_url+'other/foo.txt').hexdigest()).lower()
True
>>> cat(path)
This is a foo text.
Modified: zc.buildout/trunk/src/zc/buildout/tests.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/tests.py 2009-08-13 11:04:08 UTC (rev 102732)
+++ zc.buildout/trunk/src/zc/buildout/tests.py 2009-08-13 11:12:32 UTC (rev 102733)
@@ -2818,7 +2818,7 @@
tearDown=zc.buildout.testing.buildoutTearDown,
optionflags=doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS,
checker=renormalizing.RENormalizing([
- (re.compile('0x[0-9a-f]+'), '<MEM ADDRESS>'),
+ (re.compile('0x[0-9a-fA-F]+'), '<MEM ADDRESS>'),
(re.compile('http://localhost:[0-9]{4,5}/'),
'http://localhost/'),
(re.compile('[0-9a-f]{32}'), '<MD5 CHECKSUM>'),
More information about the Checkins
mailing list