示例#1
0
    def get_versions(cls, project):
        """Method called to retrieve all the versions (that can be found)
        of the projects provided, project that relies on the backend of
        this plugin.

        :arg Project project: a :class:`anitya.db.models.Project` object whose backend
            corresponds to the current plugin.
        :return: a list of all the possible releases found
        :return type: list
        :raise AnityaPluginException: a
            :class:`anitya.lib.exceptions.AnityaPluginException` exception
            when the versions cannot be retrieved correctly

        """
        url = cls.get_version_url(project)
        versions = []
        versions = _get_versions(url)

        if not versions:
            raise AnityaPluginException("No versions found for %s" %
                                        project.name.lower())

        # Filter retrieved versions
        filtered_versions = BaseBackend.filter_versions(
            versions, project.version_filter)
        return filtered_versions
示例#2
0
文件: gnome.py 项目: mscherer/anitya
def use_gnome_cache_json(project):
    """Try retrieving the specified project's versions using the cache.json
    file if there is one.
    """
    output = []
    url = GnomeBackend.get_version_url(project) + "cache.json"
    req = BaseBackend.call_url(url)
    data = req.json()
    for item in data:
        if (isinstance(item, dict) and project.name in item
                and isinstance(item[project.name], list)):
            output = item[project.name]

    # Filter retrieved versions
    filtered_versions = BaseBackend.filter_versions(output,
                                                    project.version_filter)
    return filtered_versions
示例#3
0
文件: gnome.py 项目: odra/anitya
def use_gnome_cache_json(project):
    ''' Try retrieving the specified project's versions using the cache.json
    file if there is one.
    '''
    output = []
    url = GnomeBackend.get_version_url(project) + "cache.json"
    req = BaseBackend.call_url(url)
    data = req.json()
    for item in data:
        if isinstance(item, dict) and project.name in item \
                and isinstance(item[project.name], list):
            output = item[project.name]
    return output
示例#4
0
文件: gnome.py 项目: msimacek/anitya
def use_gnome_cache_json(project):
    ''' Try retrieving the specified project's versions using the cache.json
    file if there is one.
    '''
    output = []
    url = 'https://download.gnome.org/sources/%(name)s/cache.json' % {
        'name': project.name}
    req = BaseBackend.call_url(url)
    data = req.json()
    for item in data:
        if isinstance(item, dict) and project.name in item \
                and isinstance(item[project.name], list):
            output = item[project.name]
    return output
示例#5
0
def use_gnome_cache_json(project):
    ''' Try retrieving the specified project's versions using the cache.json
    file if there is one.
    '''
    output = []
    url = 'https://download.gnome.org/sources/%(name)s/cache.json' % {
        'name': project.name}
    req = BaseBackend.call_url(url)
    data = req.json()
    for item in data:
        if isinstance(item, dict) and project.name in item \
                and isinstance(item[project.name], list):
            output = item[project.name]
    return output
示例#6
0
def use_gnome_cache_json(project):
    """ Try retrieving the specified project's versions using the cache.json
    file if there is one.
    """
    output = []
    url = GnomeBackend.get_version_url(project) + "cache.json"
    req = BaseBackend.call_url(url)
    data = req.json()
    for item in data:
        if (
            isinstance(item, dict)
            and project.name in item
            and isinstance(item[project.name], list)
        ):
            output = item[project.name]
    return output
示例#7
0
    def get_versions(cls, project):
        """Method called to retrieve all the versions (that can be found)
        of the projects provided, project that relies on the backend of
        this plugin.

        :arg Project project: a :class:`anitya.db.models.Project` object whose backend
            corresponds to the current plugin.
        :return: a list of all the possible releases found
        :return type: list
        :raise AnityaPluginException: a
            :class:`anitya.lib.exceptions.AnityaPluginException` exception
            when the versions cannot be retrieved correctly

        """
        url = cls.get_version_url(project)
        last_change = project.get_time_last_created_version()

        try:
            req = cls.call_url(url, last_change=last_change)
        except Exception:  # pragma: no cover
            raise AnityaPluginException("Could not contact %s" % url)

        # Not modified
        if req.status_code == 304:
            return []

        try:
            data = req.json()
        except Exception:  # pragma: no cover
            raise AnityaPluginException("No JSON returned by %s" % url)

        if "error" in data or "versions" not in data:
            raise AnityaPluginException("No versions found at %s" % url)

        # Filter retrieved versions
        filtered_versions = BaseBackend.filter_versions(
            list(data["versions"].keys()), project.version_filter)
        return filtered_versions