[Distutils] easy_install: fix for new Sourceforge download pages

Hartmut Goebel h.goebel at goebel-consult.de
Sat Jul 4 22:48:11 CEST 2009


Hi,

since Sourceforge did change their download pages, easy_install is no
longer able to fetch files there-from. Shame in Sourceforge!

For one of my tools I fixed this using the following code:

......8<---------------
    def _download_html(self, url, headers, filename):
        if url.startswith('http://sourceforge.net/projects/'):
            if self._download_from_sf(url, filename):
                return
        return PackageIndex._download_html(self, url, headers, filename)

    def _download_from_sf(self, url, filename):
        page = open(filename).read()
        basename = os.path.basename(filename)
        for match in HREF.finditer(page):
            link = urlparse.urljoin(url, htmldecode(match.group(1)))
            if
link.startswith('http://downloads.sourceforge.net/sourceforge/'):
                path = urlparse.urlparse(url)[2]
                base = urllib2.unquote(path.split('/')[-1])
                if base == basename:
                    os.unlink(filename)
                    self._download_to(link, filename)
                    return True
        return False
......8<---------------

-- 
Schönen Gruß - Regards
Hartmut Goebel
Dipl.-Informatiker (univ.), CISSP, CSSLP

Goebel Consult
Spezialist für IT-Sicherheit in komplexen Umgebungen
http://www.goebel-consult.de

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4732 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20090704/9a9d2666/attachment.bin>


More information about the Distutils-SIG mailing list