Commit 1a44c5da authored by PJ Eby's avatar PJ Eby

Update for SourceForge's changed mirror page formats

--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041458
parent 483a7ec2
...@@ -463,16 +463,14 @@ class PackageIndex(Environment): ...@@ -463,16 +463,14 @@ class PackageIndex(Environment):
return self._download_svn(url, filename) return self._download_svn(url, filename)
# Check for a SourceForge header # Check for a SourceForge header
elif sf_url: elif sf_url:
if re.search(r'^<HTML><HEAD>', line, re.I): page = ''.join(list(file))
continue # skip first line if '?use_mirror=' in page:
elif re.search(r'<TITLE>Select a Mirror for File:',line): file.close();
# Sourceforge mirror page
page = file.read()
file.close()
os.unlink(filename) os.unlink(filename)
return self._download_sourceforge(url, page, tmpdir) return self._download_sourceforge(url, page, tmpdir)
break # not an index page break # not an index page
file.close() file.close()
os.unlink(filename)
raise DistutilsError("Unexpected HTML page found at "+url) raise DistutilsError("Unexpected HTML page found at "+url)
def _download_svn(self, url, filename): def _download_svn(self, url, filename):
...@@ -490,12 +488,14 @@ class PackageIndex(Environment): ...@@ -490,12 +488,14 @@ class PackageIndex(Environment):
def warn(self, msg, *args): def warn(self, msg, *args):
log.warn(msg, *args) log.warn(msg, *args)
def _download_sourceforge(self, source_url, sf_page, tmpdir): def _download_sourceforge(self, source_url, sf_page, tmpdir):
"""Download package from randomly-selected SourceForge mirror""" """Download package from randomly-selected SourceForge mirror"""
self.debug("Processing SourceForge mirror page") self.debug("Processing SourceForge mirror page")
mirror_regex = re.compile(r'HREF=(/.*?\?use_mirror=[^>]*)') mirror_regex = re.compile(r'HREF="?(/.*?\?use_mirror=[^">]*)', re.I)
urls = [m.group(1) for m in mirror_regex.finditer(sf_page)] urls = [m.group(1) for m in mirror_regex.finditer(sf_page)]
if not urls: if not urls:
raise DistutilsError( raise DistutilsError(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment