Exemplo n.º 1
0
    def _download_url(self, scheme, url, tmpdir):
        # Determine download filename
        #
        name, fragment = egg_info_for_url(url)
        if name:
            while '..' in name:
                name = name.replace('..','.').replace('\\','_')
        else:
            name = "__downloaded__"    # default if URL has no path contents

        if name.endswith('.egg.zip'):
            name = name[:-4]    # strip the extra .zip before download

        filename = os.path.join(tmpdir,name)

        # Download the file
        #
        if scheme=='svn' or scheme.startswith('svn+'):
            return self._download_svn(url, filename)
        elif scheme=='git' or scheme.startswith('git+'):
            return self._download_git(url, filename)
        elif scheme.startswith('hg+'):
            return self._download_hg(url, filename)
        elif scheme=='file':
            return url2pathname(urlparse.urlparse(url)[2])
        else:
            self.url_ok(url, True)   # raises error if not allowed
            return self._attempt_download(url, filename)
Exemplo n.º 2
0
 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="******"Doing subversion checkout from %s to %s", url, filename)
     os.system("svn checkout%s -q %s %s" % (creds, url, filename))
     return filename