Ejemplo n.º 1
0
def packager_info(packager):
    ''' Display the information about the specified packager. '''

    packages_co = pkgdblib.get_package_maintained(
        SESSION,
        packager=packager,
        poc=False,
    )

    packages = pkgdblib.get_package_maintained(
        SESSION,
        packager=packager,
        poc=True,
    )

    if not packages and not packages_co:
        flask.flash('No packager of this name found.', 'errors')
        return flask.render_template('msg.html')

    return flask.render_template(
        'packager.html',
        packager=packager,
        packages=packages,
        packages_co=packages_co,
    )
Ejemplo n.º 2
0
def packager_info(packager):
    ''' Display the information about the specified packager. '''

    packages_co = pkgdblib.get_package_maintained(
        SESSION,
        packager=packager,
        poc=False,
    )

    packages = pkgdblib.get_package_maintained(
        SESSION,
        packager=packager,
        poc=True,
    )

    if not packages and not packages_co:
        flask.flash('No packager of this name found.', 'errors')
        return flask.render_template('msg.html')

    return flask.render_template(
        'packager.html',
        packager=packager,
        packages=packages,
        packages_co=packages_co,
    )
Ejemplo n.º 3
0
def packager_info(packager):
    ''' Display the information about the specified packager. '''
    eol = flask.request.args.get('eol', False)

    packages_co = pkgdblib.get_package_maintained(
        SESSION,
        packager=packager,
        poc=False,
        eol=eol,
    )

    packages = pkgdblib.get_package_maintained(
        SESSION,
        packager=packager,
        poc=True,
        eol=eol,
    )

    packages_watch = pkgdblib.get_package_watch(
        SESSION,
        packager=packager,
        eol=eol,
    )

    # Filter out from the watch list packaged where user has commit rights
    packages_obj = set([it[0] for it in packages_co])
    packages_obj = packages_obj.union(set([it[0] for it in packages]))
    packages_watch = [
        it for it in packages_watch if it[0] not in packages_obj]

    if not packages and not packages_co and not packages_watch:
        flask.flash('No packager of this name found.', 'errors')
        return flask.render_template('msg.html')

    return flask.render_template(
        'packager.html',
        select='packagers',
        packager=packager,
        packages=packages,
        packages_co=packages_co,
        packages_watch=packages_watch,
    )
Ejemplo n.º 4
0
def packager_info(packager):
    ''' Display the information about the specified packager. '''
    eol = flask.request.args.get('eol', False)

    packages_co = pkgdblib.get_package_maintained(
        SESSION,
        packager=packager,
        poc=False,
        eol=eol,
    )

    packages = pkgdblib.get_package_maintained(
        SESSION,
        packager=packager,
        poc=True,
        eol=eol,
    )

    packages_watch = pkgdblib.get_package_watch(
        SESSION,
        packager=packager,
        eol=eol,
    )

    # Filter out from the watch list packaged where user has commit rights
    packages_obj = set([it[0] for it in packages_co])
    packages_obj = packages_obj.union(set([it[0] for it in packages]))
    packages_watch = [it for it in packages_watch if it[0] not in packages_obj]

    if not packages and not packages_co and not packages_watch:
        flask.flash('No packager of this name found.', 'errors')
        return flask.render_template('msg.html')

    return flask.render_template(
        'packager.html',
        select='packagers',
        packager=packager,
        packages=packages,
        packages_co=packages_co,
        packages_watch=packages_watch,
    )
Ejemplo n.º 5
0
def api_packager_stats(packagername=None):
    '''
    User's stats
    ------------
    Give some stats about the ACLs of the user.

    ::

        /api/packager/stats/<fas_username>/

        /api/packager/stats/?packagername=<username>

    Accepts GET queries only.

    :arg packagername: String of the packager name.
    :kwarg eol: a boolean to specify whether to include results for
        EOL collections or not. Defaults to False.
        If ``True``, it will return results for all collections (including
        EOL).
        If ``False``, it will return results only for non-EOL collections.

    Sample response:

    ::

        /api/packager/stats/pingou

        {
          "EL-6": {
            "co-maintainer": 8,
            "point of contact": 12
          },
          "master": {
            "co-maintainer": 12,
            "point of contact": 60
          },
          "f19": {
            "co-maintainer": 12,
            "point of contact": 60
          },
          "f20": {
            "co-maintainer": 12,
            "point of contact": 60
          },
          "output": "ok"
        }


        /api/packager/stats/?packagername=random

        {
          "EL-6": {
            "co-maintainer": 0,
            "point of contact": 0
          },
          "master": {
            "co-maintainer": 0,
            "point of contact": 0
          },
          "f19": {
            "co-maintainer": 0,
            "point of contact": 0
          },
          "f20": {
            "co-maintainer": 0,
            "point of contact": 0
          },
          "output": "ok"
        }

    '''

    httpcode = 200
    output = {}

    packagername = flask.request.args.get('packagername', None) or packagername
    eol = flask.request.args.get('eol', False)

    if packagername:
        if not eol:
            collections = pkgdblib.search_collection(SESSION,
                                                     '*',
                                                     status='Active')
            collections.extend(
                pkgdblib.search_collection(SESSION,
                                           '*',
                                           status='Under Development'))
        else:
            collections = pkgdblib.search_collection(SESSION, '*')

        for collection in collections:
            packages_co = pkgdblib.get_package_maintained(
                SESSION,
                packager=packagername,
                poc=False,
                branch=collection.branchname)

            packages = pkgdblib.get_package_maintained(
                SESSION,
                packager=packagername,
                poc=True,
                branch=collection.branchname)
            output[collection.branchname] = {
                'point of contact': len(packages),
                'co-maintainer': len(packages_co)
            }
        output['output'] = 'ok'
    else:
        output = {'output': 'notok', 'error': 'Invalid request'}
        httpcode = 500

    jsonout = flask.jsonify(output)
    jsonout.status_code = httpcode
    return jsonout
Ejemplo n.º 6
0
def api_packager_package(packagername=None):
    '''
    User's packages
    ---------------
    List the packages of the user.

    ::

        /api/packager/package/<fas_username>/

        /api/packager/package/?packagername=<username>

    Accepts GET queries only.

    :arg packagername: String of the packager name.
    :kwarg eol: a boolean to specify whether to include results for
        EOL collections or not. Defaults to False.
        If ``True``, it will return results for all collections (including
        EOL).
        If ``False``, it will return results only for non-EOL collections.

    Sample response:

    ::

        /api/packager/acl/pingou

        {
          "output": "ok",
          "co-maintained": [
            {
              "acls": [],
              "status": "Approved",
              "upstream_url": null,
              "description": null,
              "summary": "Data of T- and B-cell Acute Lymphocytic "
                         "Leukemia",
              "creation_date": 1384775354.0,
              "review_url": null,
              "name": "R-ALL"

            }
          ],
          "watch": [],
          "point of contact": [
            {
              "status": "Approved",
              "upstream_url": null,
              "description": null,
              "summary": "Data of T- and B-cell Acute Lymphocytic "
                         "Leukemia",
              "creation_date": 1384775354.0,
              "review_url": null,
              "name": "R-ALL",
              "acls": []
            }
          ]
        }

        /api/packager/package/?packagername=random

        {
          "output": "notok",
          "co-maintained": [],
          "point of contact": [],
          "watch": [],
          "error": "No ACLs found for that user"
        }

    '''
    httpcode = 200
    output = {'output': 'ok'}

    packagername = flask.request.args.get('packagername', None) or packagername
    branches = flask.request.args.getlist('branches', None)
    eol = flask.request.args.get('eol', False)

    if not branches:
        branches = [None]

    packages = []
    packages_co = []
    packages_watch = []
    for branch in branches:

        tmp = pkgdblib.get_package_maintained(
            SESSION,
            packager=packagername,
            poc=False,
            branch=branch,
            eol=eol,
        )
        for pkg in tmp:
            if pkg[0] not in packages_co:
                packages_co.append(pkg[0])

        tmp_co = pkgdblib.get_package_maintained(
            SESSION,
            packager=packagername,
            poc=True,
            branch=branch,
            eol=eol,
        )
        for pkg in tmp_co:
            if pkg[0] not in packages:
                packages.append(pkg[0])

        tmp_w = pkgdblib.get_package_watch(
            SESSION,
            packager=packagername,
            branch=branch,
            eol=eol,
        )
        for pkg in tmp_w:
            if pkg[0] not in packages_watch:
                packages_watch.append(pkg[0])

    output['point of contact'] = [pkg.to_json(acls=False) for pkg in packages]
    output['co-maintained'] = [pkg.to_json(acls=False) for pkg in packages_co]
    output['watch'] = [
        pkg.to_json(acls=False) for pkg in packages_watch
        if pkg not in packages and pkg not in packages_co
    ]

    if not packages and not packages_co and not packages_watch:
        output['output'] = 'notok'
        output['error'] = 'No ACLs found for that user'
        httpcode = 404

    jsonout = flask.jsonify(output)
    jsonout.status_code = httpcode
    return jsonout
Ejemplo n.º 7
0
def api_packager_stats(packagername=None):
    '''
User's stats
------------
    Give some stats about the ACLs of the user.

    ::

        /api/packager/stats/<fas_username>/

        /api/packager/stats/?packagername=<username>

    Accept GET queries only.

    :arg packagername: String of the packager name.

    Sample response:

    ::

        /api/packager/stats/pingou

        {
          "EL-6": {
            "co-maintainer": 8,
            "point of contact": 12
          },
          "devel": {
            "co-maintainer": 12,
            "point of contact": 60
          },
          "f19": {
            "co-maintainer": 12,
            "point of contact": 60
          },
          "f20": {
            "co-maintainer": 12,
            "point of contact": 60
          },
          "output": "ok"
        }


        /api/packager/stats/?packagername=random

        {
          "EL-6": {
            "co-maintainer": 0,
            "point of contact": 0
          },
          "devel": {
            "co-maintainer": 0,
            "point of contact": 0
          },
          "f19": {
            "co-maintainer": 0,
            "point of contact": 0
          },
          "f20": {
            "co-maintainer": 0,
            "point of contact": 0
          },
          "output": "ok"
        }

    '''

    httpcode = 200
    output = {}

    packagername = flask.request.args.get('packagername', None) or packagername

    if packagername:
        collections = pkgdblib.search_collection(SESSION,
                                                 '*',
                                                 status='Active',
                                                 limit=10000)
        collections.extend(
            pkgdblib.search_collection(SESSION,
                                       '*',
                                       status='Under Development',
                                       limit=10000))
        for collection in collections:
            packages_co = pkgdblib.get_package_maintained(
                SESSION,
                packager=packagername,
                poc=False,
                branch=collection.branchname)

            packages = pkgdblib.get_package_maintained(
                SESSION,
                packager=packagername,
                poc=True,
                branch=collection.branchname)
            output[collection.branchname] = {
                'point of contact': len(packages),
                'co-maintainer': len(packages_co)
            }
        output['output'] = 'ok'
    else:
        output = {'output': 'notok', 'error': 'Invalid request'}
        httpcode = 500

    jsonout = flask.jsonify(output)
    jsonout.status_code = httpcode
    return jsonout
Ejemplo n.º 8
0
def api_packager_stats(packagername=None):
    '''
User's stats
------------
    Give some stats about the ACLs of the user.

    ::

        /api/packager/stats/<fas_username>/

        /api/packager/stats/?packagername=<username>

    Accept GET queries only.

    :arg packagername: String of the packager name.
    :kwarg eol: a boolean to specify whether to include results for
        EOL collections or not. Defaults to False.
        If ``True``, it will return results for all collections (including
        EOL).
        If ``False``, it will return results only for non-EOL collections.

    Sample response:

    ::

        /api/packager/stats/pingou

        {
          "EL-6": {
            "co-maintainer": 8,
            "point of contact": 12
          },
          "master": {
            "co-maintainer": 12,
            "point of contact": 60
          },
          "f19": {
            "co-maintainer": 12,
            "point of contact": 60
          },
          "f20": {
            "co-maintainer": 12,
            "point of contact": 60
          },
          "output": "ok"
        }


        /api/packager/stats/?packagername=random

        {
          "EL-6": {
            "co-maintainer": 0,
            "point of contact": 0
          },
          "master": {
            "co-maintainer": 0,
            "point of contact": 0
          },
          "f19": {
            "co-maintainer": 0,
            "point of contact": 0
          },
          "f20": {
            "co-maintainer": 0,
            "point of contact": 0
          },
          "output": "ok"
        }

    '''

    httpcode = 200
    output = {}

    packagername = flask.request.args.get('packagername', None) or packagername
    eol = flask.request.args.get('eol', False)

    if packagername:
        if not eol:
            collections = pkgdblib.search_collection(
                SESSION, '*', status='Active')
            collections.extend(pkgdblib.search_collection(
                SESSION, '*', status='Under Development'))
        else:
            collections = pkgdblib.search_collection(SESSION, '*')

        for collection in collections:
            packages_co = pkgdblib.get_package_maintained(
                SESSION,
                packager=packagername,
                poc=False,
                branch=collection.branchname
            )

            packages = pkgdblib.get_package_maintained(
                SESSION,
                packager=packagername,
                poc=True,
                branch=collection.branchname
            )
            output[collection.branchname] = {
                'point of contact': len(packages),
                'co-maintainer': len(packages_co)
            }
        output['output'] = 'ok'
    else:
        output = {'output': 'notok', 'error': 'Invalid request'}
        httpcode = 500

    jsonout = flask.jsonify(output)
    jsonout.status_code = httpcode
    return jsonout
Ejemplo n.º 9
0
def api_packager_package(packagername=None):
    '''
User's packages
---------------
    List the packages of the user.

    ::

        /api/packager/package/<fas_username>/

        /api/packager/package/?packagername=<username>

    Accept GET queries only.

    :arg packagername: String of the packager name.
    :kwarg eol: a boolean to specify whether to include results for
        EOL collections or not. Defaults to False.
        If ``True``, it will return results for all collections (including
        EOL).
        If ``False``, it will return results only for non-EOL collections.

    Sample response:

    ::

        /api/packager/acl/pingou

        {
          "output": "ok",
          "co-maintained": [
            {
              "acls": [],
              "status": "Approved",
              "upstream_url": null,
              "description": null,
              "summary": "Data of T- and B-cell Acute Lymphocytic "
                         "Leukemia",
              "creation_date": 1384775354.0,
              "review_url": null,
              "name": "R-ALL"

            }
          ],
          "watch": [],
          "point of contact": [
            {
              "status": "Approved",
              "upstream_url": null,
              "description": null,
              "summary": "Data of T- and B-cell Acute Lymphocytic "
                         "Leukemia",
              "creation_date": 1384775354.0,
              "review_url": null,
              "name": "R-ALL",
              "acls": []
            }
          ]
        }

        /api/packager/package/?packagername=random

        {
          "output": "notok",
          "co-maintained": [],
          "point of contact": [],
          "watch": [],
          "error": "No ACLs found for that user"
        }

    '''
    httpcode = 200
    output = {'output': 'ok'}

    packagername = flask.request.args.get('packagername', None) or packagername
    eol = flask.request.args.get('eol', False)

    packages_co = pkgdblib.get_package_maintained(
        SESSION,
        packager=packagername,
        poc=False,
        eol=eol,
    )
    seen = []
    for pkg in packages_co:
        if pkg[0] not in seen:
            seen.append(pkg[0])
    packages_co = seen

    packages = pkgdblib.get_package_maintained(
        SESSION,
        packager=packagername,
        poc=True,
        eol=eol,
    )
    seen = []
    for pkg in packages:
        if pkg[0] not in seen:
            seen.append(pkg[0])
    packages = seen

    packages_watch = pkgdblib.get_package_watch(
        SESSION,
        packager=packagername,
        eol=eol,
    )
    seen = []
    for pkg in packages_watch:
        if pkg[0] not in seen:
            seen.append(pkg[0])
    packages_watch = seen

    output['point of contact'] = [pkg.to_json(acls=False) for pkg in packages]
    output['co-maintained'] = [pkg.to_json(acls=False) for pkg in packages_co]
    output['watch'] = [pkg.to_json(acls=False) for pkg in packages_watch]

    if not packages and not packages_co and not packages_watch:
        output['output'] = 'notok'
        output['error'] = 'No ACLs found for that user'
        httpcode = 404

    jsonout = flask.jsonify(output)
    jsonout.status_code = httpcode
    return jsonout
Ejemplo n.º 10
0
def api_packager_stats(packagername=None):
    '''
User's stats
------------
    Give some stats about the ACLs of the user.

    ::

        /api/packager/stats/<fas_username>/

        /api/packager/stats/?packagername=<username>

    Accept GET queries only.

    :arg packagername: String of the packager name.

    Sample response:

    ::

        /api/packager/stats/pingou

        {
          "EL-6": {
            "co-maintainer": 8,
            "point of contact": 12
          },
          "devel": {
            "co-maintainer": 12,
            "point of contact": 60
          },
          "f19": {
            "co-maintainer": 12,
            "point of contact": 60
          },
          "f20": {
            "co-maintainer": 12,
            "point of contact": 60
          },
          "output": "ok"
        }


        /api/packager/stats/?packagername=random

        {
          "EL-6": {
            "co-maintainer": 0,
            "point of contact": 0
          },
          "devel": {
            "co-maintainer": 0,
            "point of contact": 0
          },
          "f19": {
            "co-maintainer": 0,
            "point of contact": 0
          },
          "f20": {
            "co-maintainer": 0,
            "point of contact": 0
          },
          "output": "ok"
        }

    '''

    httpcode = 200
    output = {}

    packagername = flask.request.args.get('packagername', None) or packagername

    if packagername:
        collections = pkgdblib.search_collection(
            SESSION, '*', status='Active', limit=10000)
        collections.extend(pkgdblib.search_collection(
            SESSION, '*', status='Under Development', limit=10000))
        for collection in collections:
            packages_co = pkgdblib.get_package_maintained(
                SESSION,
                packager=packagername,
                poc=False,
                branch=collection.branchname
            )

            packages = pkgdblib.get_package_maintained(
                SESSION,
                packager=packagername,
                poc=True,
                branch=collection.branchname
            )
            output[collection.branchname] = {
                'point of contact': len(packages),
                'co-maintainer': len(packages_co)
            }
        output['output'] = 'ok'
    else:
        output = {'output': 'notok', 'error': 'Invalid request'}
        httpcode = 500

    jsonout = flask.jsonify(output)
    jsonout.status_code = httpcode
    return jsonout