summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorphillip.eby <phillip.eby@6015fed2-1504-0410-9fe1-9d1591cc4771>2011-03-23 20:35:42 +0000
committerphillip.eby <phillip.eby@6015fed2-1504-0410-9fe1-9d1591cc4771>2011-03-23 20:35:42 +0000
commit1960f7454e842451a4c2bb27b3488ea97b13e747 (patch)
tree2308e1c2b5d24dd425147b211b28a7f92ac0adb8
parentf6215960d2636ef84b06b27614c2fcec73cbd13c (diff)
downloadpython-setuptools-1960f7454e842451a4c2bb27b3488ea97b13e747.tar.gz
Handle multiple Content-Length headers, and support HTTP credentials for
SVN checkouts. git-svn-id: http://svn.python.org/projects/sandbox/trunk/setuptools@88792 6015fed2-1504-0410-9fe1-9d1591cc4771
-rwxr-xr-xsetuptools/package_index.py45
1 files changed, 43 insertions, 2 deletions
diff --git a/setuptools/package_index.py b/setuptools/package_index.py
index 32498d0..9a9c5d6 100755
--- a/setuptools/package_index.py
+++ b/setuptools/package_index.py
@@ -550,7 +550,7 @@ class PackageIndex(Environment):
bs = self.dl_blocksize
size = -1
if "content-length" in headers:
- size = int(headers["Content-Length"])
+ size = max(map(int,headers.getheaders("Content-Length")))
self.reporthook(url, filename, blocknum, bs, size)
tfp = open(filename,'wb')
while True:
@@ -639,10 +639,39 @@ class PackageIndex(Environment):
os.unlink(filename)
raise DistutilsError("Unexpected HTML page found at "+url)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
def _download_svn(self, url, filename):
url = url.split('#',1)[0] # remove any fragment for svn's sake
+ creds = ''
+ if url.lower().startswith('svn:') and '@' in url:
+ scheme, netloc, path, p, q, f = urlparse.urlparse(url)
+ if not netloc and path.startswith('//') and '/' in path[2:]:
+ netloc, path = path[2:].split('/',1)
+ auth, host = urllib.splituser(netloc)
+ if auth:
+ if ':' in auth:
+ user, pw = auth.split(':',1)
+ creds = " --username=%s --password=%s" % (user, pw)
+ else:
+ creds = " --username="+auth
+ netloc = host
+ url = urlparse.urlunparse((scheme, netloc, url, p, q, f))
self.info("Doing subversion checkout from %s to %s", url, filename)
- os.system("svn checkout -q %s %s" % (url, filename))
+ os.system("svn checkout%s -q %s %s" % (creds, url, filename))
return filename
def debug(self, msg, *args):
@@ -654,6 +683,18 @@ class PackageIndex(Environment):
def warn(self, msg, *args):
log.warn(msg, *args)
+
+
+
+
+
+
+
+
+
+
+
+
# This pattern matches a character entity reference (a decimal numeric
# references, a hexadecimal numeric reference, or a named reference).
entity_sub = re.compile(r'&(#(\d+|x[\da-fA-F]+)|[\w.:-]+);?').sub