def download(self, source, dest):
        """
        Download an archive file.

        :param str source: URL pointing to an archive file.
        :param str dest: Local path location to download archive file to.
        """
        # propagate all exceptions
        # URLError, OSError, etc
        proto, netloc, path, params, query, fragment = urlparse(source)
        if proto in ('http', 'https'):
            auth, barehost = splituser(netloc)
            if auth is not None:
                source = urlunparse((proto, barehost, path, params, query, fragment))
                username, password = splitpasswd(auth)
                passman = HTTPPasswordMgrWithDefaultRealm()
                # Realm is set to None in add_password to force the username and password
                # to be used whatever the realm
                passman.add_password(None, source, username, password)
                authhandler = HTTPBasicAuthHandler(passman)
                opener = build_opener(authhandler)
                install_opener(opener)
        response = urlopen(source)
        try:
            with open(dest, 'wb') as dest_file:
                dest_file.write(response.read())
        except Exception as e:
            if os.path.isfile(dest):
                os.unlink(dest)
            raise e
def download ( self , source , dest ) : proto , netloc , path , params , query , fragment = urlparse ( source ) if proto in ( 'http' , 'https' ) : auth , barehost = splituser ( netloc ) if auth is not None : source = urlunparse ( ( proto , barehost , path , params , query , fragment ) ) username , password = splitpasswd ( auth ) passman = HTTPPasswordMgrWithDefaultRealm ( ) passman . add_password ( None , source , username , password ) authhandler = HTTPBasicAuthHandler ( passman ) opener = build_opener ( authhandler ) install_opener ( opener ) response = urlopen ( source ) try : with open ( dest , 'wb' ) as dest_file : dest_file . write ( response . read ( ) ) except Exception as e : if os . path . isfile ( dest ) : os . unlink ( dest ) raise e
Download an archive file.

        :param str source: URL pointing to an archive file.
        :param str dest: Local path location to download archive file to.