Esempio n. 1
0
def metapackages(bound=None):
    # process search
    filterinfo = MetapackagesFilterInfo()
    filterinfo.ParseFlaskArgs()

    request = filterinfo.GetRequest()
    request.Bound(bound)

    # get packages
    packages = get_db().GetMetapackages(request,
                                        limit=config['METAPACKAGES_PER_PAGE'])

    # on empty result, fallback to show first, last set of results
    if not packages:
        request = filterinfo.GetRequest()
        if bound and bound.startswith('..'):
            request.NameTo(None)
        packages = get_db().GetMetapackages(
            request, limit=config['METAPACKAGES_PER_PAGE'])

    firstname, lastname = get_packages_name_range(packages)

    metapackagedata = metapackages_to_summary_items(
        PackagesToMetapackages(packages), filterinfo.GetRepo(),
        filterinfo.GetMaintainer())

    return flask.render_template('metapackages.html',
                                 firstname=firstname,
                                 lastname=lastname,
                                 search=filterinfo.GetDict(),
                                 advanced=filterinfo.IsAdvanced(),
                                 metapackagedata=metapackagedata,
                                 repo=filterinfo.GetRepo(),
                                 maintainer=filterinfo.GetMaintainer())
Esempio n. 2
0
def api_v1_metapackages_generic(bound, *filters):
    metapackages = PackagesToMetapackages(get_db().GetMetapackages(
        bound_to_filter(bound),
        *filters,
        limit=config['METAPACKAGES_PER_PAGE']))

    metapackages = {
        metapackage_name: list(map(api_v1_package_to_json, packageset))
        for metapackage_name, packageset in metapackages.items()
    }

    return (json.dumps(metapackages), {'Content-type': 'application/json'})
Esempio n. 3
0
def metapackage_related(name):
    packages = get_db().GetRelatedMetapackages(name, limit=config['METAPACKAGES_PER_PAGE'])

    metapackagedata = metapackages_to_summary_items(PackagesToMetapackages(packages))

    too_many_warning = None
    if len(metapackagedata) == config['METAPACKAGES_PER_PAGE']:
        too_many_warning = config['METAPACKAGES_PER_PAGE']

    return flask.render_template(
        'metapackage-related.html',
        name=name,
        metapackagedata=metapackagedata,
        too_many_warning=too_many_warning
    )
Esempio n. 4
0
def metapackages(bound=None):
    # process search
    filterinfo = MetapackagesFilterInfo()
    filterinfo.ParseFlaskArgs()

    request = filterinfo.GetRequest()
    request.Bound(bound)

    # get packages
    def get_packages(request):
        metapackages = get_db().query_metapackages(
            **request.__dict__,
            limit=config['METAPACKAGES_PER_PAGE'],
        )

        packages = get_db().get_metapackages_packages(
            list(metapackages.keys()),
            fields=[
                'repo', 'family', 'effname', 'version', 'versionclass',
                'maintainers', 'flags'
            ])

        return metapackages, packages

    metapackages, packages = get_packages(request)

    # on empty result, fallback to show first, last set of results
    if not packages:
        request = filterinfo.GetRequest()
        if bound and bound.startswith('..'):
            request.NameTo(None)
        metapackages, packages = get_packages(request)

    firstname, lastname = get_packages_name_range(packages)

    metapackagedata = metapackages_to_summary_items(
        PackagesToMetapackages(packages), filterinfo.GetRepo(),
        filterinfo.GetMaintainer())

    return flask.render_template('metapackages.html',
                                 firstname=firstname,
                                 lastname=lastname,
                                 search=filterinfo.GetDict(),
                                 advanced=filterinfo.IsAdvanced(),
                                 metapackages=metapackages,
                                 metapackagedata=metapackagedata,
                                 repo=filterinfo.GetRepo(),
                                 maintainer=filterinfo.GetMaintainer())
Esempio n. 5
0
def metapackages_generic(bound,
                         *filters,
                         template='metapackages.html',
                         repo=None,
                         maintainer=None):
    namefilter = bound_to_filter(bound)

    # process search
    search = flask.request.args.to_dict().get('search')
    search = None if search is None else search.strip()
    searchfilter = NameSubstringQueryFilter(search) if search else None

    # get packages
    packages = get_db().GetMetapackages(namefilter,
                                        InAnyRepoQueryFilter(reponames),
                                        searchfilter,
                                        *filters,
                                        limit=config['METAPACKAGES_PER_PAGE'])

    # on empty result, fallback to show first, last set of results
    if not packages:
        if bound and bound.startswith('<'):
            namefilter = NameStartingQueryFilter()
        else:
            namefilter = NameBeforeQueryFilter()
        packages = get_db().GetMetapackages(
            namefilter,
            InAnyRepoQueryFilter(reponames),
            searchfilter,
            *filters,
            limit=config['METAPACKAGES_PER_PAGE'])

    firstname, lastname = get_packages_name_range(packages)

    metapackagedata = metapackages_to_summary_items(
        PackagesToMetapackages(packages), repo, maintainer)

    return flask.render_template(template,
                                 firstname=firstname,
                                 lastname=lastname,
                                 search=search,
                                 metapackagedata=metapackagedata,
                                 repo=repo,
                                 maintainer=maintainer)
Esempio n. 6
0
def api_v1_metapackages(bound=None):
    filterinfo = MetapackagesFilterInfo()
    filterinfo.ParseFlaskArgs()

    request = filterinfo.GetRequest()
    request.Bound(bound)

    packages = get_db().GetMetapackages(request,
                                        limit=config['METAPACKAGES_PER_PAGE'])

    metapackages = PackagesToMetapackages(packages)

    metapackages = {
        metapackage_name:
        [api_v1_package_to_json(package) for package in packageset]
        for metapackage_name, packageset in metapackages.items()
    }

    return (json.dumps(metapackages), {'Content-type': 'application/json'})
Esempio n. 7
0
def metapackage_related(name):
    name = name.lower()

    metapackages = get_db().get_metapackage_related_metapackages(
        name, limit=config['METAPACKAGES_PER_PAGE'])

    packages = get_db().get_metapackages_packages(
        list(metapackages.keys()),
        fields=['family', 'effname', 'version', 'versionclass', 'flags'])

    metapackagedata = metapackages_to_summary_items(
        PackagesToMetapackages(packages))

    too_many_warning = None
    if len(metapackagedata) == config['METAPACKAGES_PER_PAGE']:
        too_many_warning = config['METAPACKAGES_PER_PAGE']

    return flask.render_template('metapackage-related.html',
                                 name=name,
                                 metapackages=metapackages,
                                 metapackagedata=metapackagedata,
                                 too_many_warning=too_many_warning)
Esempio n. 8
0
def index():
    repostats = [
        repo for repo in get_db().GetRepositories()
        if repo['name'] in reponames
        and repometadata[repo['name']]['type'] == 'repository'
    ]

    top_repos = {
        'by_total': [{
            'name': repo['name'],
            'value': repo['num_metapackages'],
        } for repo in sorted(
            repostats, key=lambda repo: repo['num_metapackages'], reverse=True)
                     ][:10],
        'by_nonunique': [{
            'name':
            repo['name'],
            'value':
            repo['num_metapackages_newest'] +
            repo['num_metapackages_outdated'],
        } for repo in sorted(repostats,
                             key=lambda repo: repo['num_metapackages_newest'] +
                             repo['num_metapackages_outdated'],
                             reverse=True)][:10],
        'by_newest': [{
            'name': repo['name'],
            'value': repo['num_metapackages_newest'],
        } for repo in sorted(repostats,
                             key=lambda repo: repo['num_metapackages_newest'],
                             reverse=True)][:10],
        'by_pnewest': [{
            'name':
            repo['name'],
            'value':
            '{:.2f}%'.format(
                safe_percent(
                    repo['num_metapackages_newest'], repo['num_metapackages'] -
                    repo['num_metapackages_unique'])),
        } for repo in sorted(
            repostats,
            key=lambda repo: safe_percent(
                repo['num_metapackages_newest'], repo['num_metapackages'] -
                repo['num_metapackages_unique']),
            reverse=True) if repo['num_metapackages'] > 1000][:8]
    }

    important_packages = [
        'apache24',
        'awesome',
        'bash',
        'binutils',
        'bison',
        'blender',
        'boost',
        'bzip2',
        'chromium',
        'claws-mail',
        'cmake',
        'cppcheck',
        'cups',
        'curl',
        'darktable',
        'dia',
        'djvulibre',
        'dosbox',
        'dovecot',
        'doxygen',
        'dvd+rw-tools',
        'emacs',
        'exim',
        'ffmpeg',
        'firefox',
        'flex',
        'fluxbox',
        'freecad',
        'freetype',
        'gcc',
        'gdb',
        'geeqie',
        'gimp',
        'git',
        'gnupg',
        'go',
        'graphviz',
        'grub',
        'icewm',
        'imagemagick',
        'inkscape',
        'irssi',
        'kodi',
        'lame',
        'lftp',
        'libreoffice',
        'libressl',
        'lighttpd',
        'links',
        'llvm',
        'mariadb',
        'maxima',
        'mc',
        'memcached',
        'mercurial',
        'mesa',
        'mplayer',
        'mutt',
        'mysql',
        'nginx',
        'nmap',
        'octave',
        'openbox',
        'openssh',
        'openssl',
        'openttf',
        'openvpn',
        'p7zip',
        'perl',
        'pidgin',
        'postfix',
        'postgresql',
        'privoxy',
        'procmail',
        'python3',
        'qemu',
        'rdesktop',
        'redis',
        'rrdtool',
        'rsync',
        'rtorrent',
        'rxvt-unicode',
        'samba',
        'sane-backends',
        'scons',
        'screen',
        'scribus',
        'scummvm',
        'sdl2',
        'smartmontools',
        'sqlite3',
        'squid',
        'subversion',
        'sudo',
        'sumversion',
        'thunderbird',
        'tigervnc',
        'tmux',
        'tor',
        'valgrind',
        'vim',
        'virtualbox',
        'vlc',
        'vsftpd',
        'wayland',
        'wesnoth',
        'wget',
        'wine',
        'wireshark',
        'xorg-server',
        'youtube-dl',
        'zsh',
    ]

    packages = get_db().GetMetapackage(important_packages)

    metapackagedata = metapackages_to_summary_items(
        PackagesToMetapackages(packages))

    return flask.render_template('index.html',
                                 top_repos=top_repos,
                                 metapackagedata=metapackagedata)