Пример #1
0
def path_help(path=None):
    """Redirects to the API description containing the path_help"""
    if path is None:
        return bottle.HTTPError(503, 'Path not specified.')

    redirect("https://ftp-master.debian.org/epydoc/%s-module.html#%s" %
             (QueryRegister().get_path_help(path), path))
Пример #2
0
from daklib.dbconn import DBConn, Archive
from dakweb.webregister import QueryRegister


@bottle.route('/archives')
def archives():
    """
    Give information about all known archives (sets of suites)

    @rtype: dict
    return: list of dictionaries
    """

    s = DBConn().session()
    q = s.query(Archive)
    q = q.order_by(Archive.archive_name)
    ret = []
    for a in q:
        ret.append({
            'name': a.archive_name,
            'suites': [x.suite_name for x in a.suites]
        })

    s.close()

    bottle.response.content_type = 'application/json; charset=UTF-8'
    return json.dumps(ret)


QueryRegister().register_path('/archives', archives)
Пример #3
0
    List all possible metadata keys

    @rtype: dictionary
    @return: A list of metadata keys
    """
    s = DBConn().session()
    q = s.query(MetadataKey)
    ret = []
    for p in q:
        ret.append( p.key)

    s.close()

    return json.dumps(ret)

QueryRegister().register_path('/metadata_keys', binary_metadata_keys)


@bottle.route('/binary/by_metadata/<key>')
def binary_by_metadata(key=None):
    """

    Finds all Debian binary packages which have the specified metadata set.

    E.g., to find out the Go import paths of all Debian Go packages, query
    /binary/by_metadata/Go-Import-Path.

    @type key: string
    @param key: Metadata key to search for.

    @rtype: dictionary
Пример #4
0
@license: GNU General Public License version 2 or later
"""

import bottle
from bottle import redirect
from daklib.dbconn import DBConn
import json

from dakweb.webregister import QueryRegister


@bottle.route('/')
def root_path():
    """Returns a useless welcome message"""
    return json.dumps('Use the /list_paths path to list all available paths')
QueryRegister().register_path('/', root_path)


@bottle.route('/list_paths')
def list_paths():
    """Returns a list of available paths"""
    redirect("https://ftp-master.debian.org/epydoc/dakweb-module.html#__package__")
QueryRegister().register_path('/list_paths', list_paths)


@bottle.route('/path_help/<path>')
def path_help(path=None):
    """Redirects to the API description containing the path_help"""
    if path is None:
        return bottle.HTTPError(503, 'Path not specified.')
Пример #5
0
    binary_type = r.query.get('b', None)
    if binary_type is not None:
        kwargs['binary_types'] = [binary_type]
    component = r.query.get('c', None)
    if component is not None:
        kwargs['components'] = component.split(",")
    suite = r.query.get('s', None)
    if suite is not None:
        kwargs['suites'] = suite.split(",")
    if 'S' in r.query:
        kwargs['source_and_binary'] = True
    #if 'r' in r.query:
    #    kwargs['regex'] = True
    format = r.query.get('f', None)
    if format is not None:
        kwargs['format'] = 'python'

    result = list_packages(packages, **kwargs)

    if format is None:
        bottle.response.content_type = 'text/plain'
        for row in result:
            yield row
            yield "\n"
    else:
        yield json.dumps(list(result))


QueryRegister().register_path('/madison', madison)
Пример #6
0
    q = q.filter(DBSource.source == source)
    q = q.filter(PoolFile.filename.endswith('.dsc'))
    ret = []
    for p in q:
        ret.append({'version':   p.source.version,
                    'component': p.poolfile.component.component_name,
                    'filename':  p.poolfile.filename,
                    'filesize':  p.poolfile.filesize,
                    'sha256sum': p.poolfile.sha256sum})

    s.close()

    bottle.response.content_type = 'application/json; charset=UTF-8'
    return json.dumps(ret)

QueryRegister().register_path('/dsc_in_suite', dsc_in_suite)


@bottle.route('/file_in_archive/<filepattern:path>')
def file_in_archive(filepattern=None):
    """
    Check if a file pattern is known to the archive. Note that the
    patterns are matched against the location of the files in the
    pool, so for %tmux_2.3-1.dsc it will return t/tmux/tmux_2.3-1.dsc
    as filename.

    @since: October 2016

    @type filepattern: string

    @param filepattern: Pattern of the filenames to match. SQL LIKE
Пример #7
0
    for p in q:
        ret.append({
            'name': p.release_suite_output,
            'codename': p.codename,
            'dakname': p.suite_name,
            'archive': p.archive.archive_name,
            'architectures': [x.arch_string for x in p.architectures],
            'components': [x.component_name for x in p.components]
        })

    s.close()

    return json.dumps(ret)


QueryRegister().register_path('/suites', suites)


@bottle.route('/suite/<suite>')
def suite(suite=None):
    """
    Gives information about a single suite.  Note that this routine will look
    up a suite first by the main suite_name, but then also by codename if no
    suite is initially found.  It can therefore be used to canonicalise suite
    names.

    @type suite: string
    @param suite: Name or codename of the suite.
    @see: L{I{suites}<dakweb.queries.suite.suites>} on how to receive a list of valid suites.

    @maps: name maps to Suite: in the release file
Пример #8
0
    ret = []
    for p in q:
        ret.append({
            'version': p.source.version,
            'component': p.poolfile.component.component_name,
            'filename': p.poolfile.filename,
            'filesize': p.poolfile.filesize,
            'sha256sum': p.poolfile.sha256sum
        })

    s.close()

    return json.dumps(ret)


QueryRegister().register_path('/dsc_in_suite', dsc_in_suite)


@bottle.route('/sources_in_suite/<suite>')
def sources_in_suite(suite=None):
    """
    Returns all source packages and their versions in a given suite.

    @since: December 2014

    @type suite: string
    @param suite: Name of the suite.
    @see: L{I{suites}<dakweb.queries.suite.suites>} on how to receive a list of valid suites.

    @rtype: list of dictionaries
    @return: Dictionaries made out of