Exemplo n.º 1
0
def get_downloader(url, repo, conduit, config, is_cancelled_call):
    """
    Returns an instance of the correct downloader to use for the given url.

    :param url: location from which to sync packages
    :type  url: str

    :param repo: describes the repository being synchronized
    :type  repo: pulp.plugins.model.Repository

    :param conduit: sync conduit used during the sync process
    :type  conduit: pulp.plugins.conduits.repo_sync.RepoSyncConduit

    :param config: configuration of the importer and call
    :type  config: pulp.plugins.config.PluginCallConfiguration

    :param is_cancelled_call: callback into the plugin to check if the sync
           has been cancelled
    :type  is_cancelled_call: func

    :return: downloader instance to use for the given url

    :raise UnsupportedURLType: if there is no applicable downloader for the
           given url
    :raise InvalidURL: if the url cannot be parsed to determine the type
    """
    url_type = url_utils.determine_url_type(url)
    downloader = get_url_type_downloader(url_type)
    return downloader(repo, conduit, config, is_cancelled_call)
Exemplo n.º 2
0
def is_valid_url(url):
    if not url or url is None:
        return False

    url_type = url_utils.determine_url_type(url)
    try:
        get_url_type_downloader(url_type)
        return True
    except UnsupportedURLType:
        return False