Пример #1
0
def __handle_request_unretire(actionid, action):
    ''' Handle unretirement requests. Do the same checks as done for new
    package requests and ask the admin to do the necessary steps by hand. '''

    bugid = action['info']['pkg_review_url'].rsplit('/', 1)[-1]
    if '=' in bugid:
        bugid = bugid.split('=', 1)[1]

    # Add valuees to info that pkgdb adds to new package actions
    action['info']['pkg_name'] = action['package']['name']
    action['info']['pkg_summary'] = action['package']['summary']
    action['info']['pkg_collection'] = action['collection'][
        'branchname']
    action['info']['pkg_poc'] = action['user']
    # FIXME : Does not need to use .get() once
    # https://github.com/fedora-infra/pkgdb2/pull/333
    # is deployed.
    action['info']['pkg_namespace'] = action['package'].get(
        'namespace', 'rpms')

    if bugid:
        msgs = utils.check_package_creation(
            action['info'], bugid, PKGDBCLIENT, action['user'])
    else:
        msgs = {
            "bad": ['No review specified, retirement recent enough?'],
            'good': []
        }

    bugid = utils.get_bug_id_from_url(action['info']['pkg_review_url'])
    decision = _ask_what_to_do(msgs)

    if decision in ('a', 'approve'):
        cmd = ("pkgdb-cli", "unorphan", "--poc", action['info']['pkg_poc'],
               action['info']['pkg_name'], action['info']['pkg_collection'])
        input("Please run the following command (confirm with any key): " +
              " ".join(cmd))
        input("Please make sure the package is properly unblocked in koji. "
              "(Confirm with any key)")

        data = approve_action(actionid)

    elif decision in ('deny', 'd'):
        data, _ = deny_action(actionid)
    else:
        data = {
            'messages': ['Action {0} un-touched'.format(actionid)]
        }
    return data
Пример #2
0
def __handle_request_unretire(actionid, action):
    ''' Handle unretirement requests. Do the same checks as done for new
    package requests and ask the admin to do the necessary steps by hand. '''

    bugid = action['info']['pkg_review_url'].rsplit('/', 1)[-1]
    if '=' in bugid:
        bugid = bugid.split('=', 1)[1]

    # Add valuees to info that pkgdb adds to new package actions
    action['info']['pkg_name'] = action['package']['name']
    action['info']['pkg_summary'] = action['package']['summary']
    action['info']['pkg_collection'] = action['collection']['branchname']
    action['info']['pkg_poc'] = action['user']
    # FIXME : Does not need to use .get() once
    # https://github.com/fedora-infra/pkgdb2/pull/333
    # is deployed.
    action['info']['pkg_namespace'] = action['package'].get(
        'namespace', 'rpms')

    if bugid:
        msgs = utils.check_package_creation(action['info'], bugid, PKGDBCLIENT,
                                            action['user'])
    else:
        msgs = {
            "bad": ['No review specified, retirement recent enough?'],
            'good': []
        }

    bugid = utils.get_bug_id_from_url(action['info']['pkg_review_url'])
    decision = _ask_what_to_do(msgs)

    if decision in ('a', 'approve'):
        cmd = ("pkgdb-cli", "unorphan", "--poc", action['info']['pkg_poc'],
               action['info']['pkg_name'], action['info']['pkg_collection'])
        input("Please run the following command (confirm with any key): " +
              " ".join(cmd))
        input("Please make sure the package is properly unblocked in koji. "
              "(Confirm with any key)")

        data = approve_action(actionid)

    elif decision in ('deny', 'd'):
        data, _ = deny_action(actionid)
    else:
        data = {'messages': ['Action {0} un-touched'.format(actionid)]}
    return data
Пример #3
0
def __handle_request_unretire(actionid, action):
    ''' Handle unretirement requests. Do the same checks as done for new
    package requests and ask the admin to do the necessary steps by hand. '''

    # Add valuees to info that pkgdb adds to new package actions
    action['info']['pkg_name'] = action['package']['name']
    action['info']['pkg_summary'] = action['package']['summary']
    action['info']['pkg_collection'] = action['collection'][
        'branchname']
    action['info']['pkg_poc'] = action['user']
    # FIXME : Does not need to use .get() once
    # https://github.com/fedora-infra/pkgdb2/pull/333
    # is deployed.
    action['info']['pkg_namespace'] = action['package'].get(
        'namespace', 'rpms')

    if action['info']['pkg_review_url']:
        bugid = utils.get_bug_id_from_url(action['info']['pkg_review_url'])
        msgs = utils.check_package_creation(
            action['info'], bugid, PKGDBCLIENT, action['user'])
    else:
        msgs = utils.check_branch_creation(
            PKGDBCLIENT, action['package']['name'],
            action['collection']['branchname'], action['user'], new_pkg=True,
            namespace=action['info']['pkg_namespace'])

        package = PKGDBCLIENT.get_package(
            action['package']['name'],
            branches=[action['info']['pkg_collection']],
            namespace=action['info']['pkg_namespace'],
        )["packages"][0]
        rawhide_package = PKGDBCLIENT.get_package(
            action['package']['name'], branches=["master"],
            namespace=action['info']['pkg_namespace'],
        )["packages"][0]

        last_pkg_change = datetime.datetime.fromtimestamp(
            package["status_change"])
        request_date = datetime.datetime.fromtimestamp(
            action['date_created'])
        delta = request_date - last_pkg_change
        if delta.days < 14:
            msgs["good"].append("Package was retired less than 14 days ago")
        elif rawhide_package.status != "Retired":
            msgs["good"].append("Package is not retired in Rawhide")
        else:
            msgs["bad"].append(
                "Package is retired in Rawhide and was retired more than "
                "14 days ago")
    if action['info'].get('pkg_review_url'):
        print('Review url {}'.format(action['info'].get('pkg_review_url')))
    else:
        print('No review url was provided with this request')

    decision = _ask_what_to_do(msgs)

    if decision in ('a', 'approve'):
        cmd = ("pkgdb-cli", "unorphan", "--poc", action['info']['pkg_poc'],
               action['info']['pkg_name'], action['info']['pkg_collection'])
        input("Please run the following command (confirm with any key): " +
              " ".join(cmd))
        input("Please make sure the package is properly unblocked in koji. "
              "(Confirm with any key)")

        data = approve_action(actionid)

    elif decision in ('deny', 'd'):
        data, _ = deny_action(actionid)
    else:
        data = {
            'messages': ['Action {0} un-touched'.format(actionid)]
        }
    return data
Пример #4
0
def __handle_request_package(actionid, action):
    ''' Handle the new package requests. '''
    bugid = utils.get_bug_id_from_url(action['info']['pkg_review_url'])
    msgs = utils.check_package_creation(
        action['info'], bugid, PKGDBCLIENT, action['user'])

    decision = _ask_what_to_do(msgs)
    if decision in ('a', 'approve'):
        desc = action['info'].get('pkg_description', None)
        if desc:
            desc = desc.encode('utf-8')
        upstream = action['info'].get('pkg_upstream_url', None)
        if upstream:
            upstream = upstream.encode('utf-8')

        monitoring_status = action['info'].get('monitoring_status', True)
        # If we get an invalid monitoring status, use the default
        if str(monitoring_status) not in ['True', 'False', 'nobuild']:
            monitoring_status = True

        data = PKGDBCLIENT.create_package(
            pkgname=action['info']['pkg_name'].encode('utf-8'),
            summary=action['info']['pkg_summary'].encode('utf-8'),
            description=desc,
            review_url=action['info']['pkg_review_url'].encode('utf-8'),
            status=action['info']['pkg_status'].encode('utf-8'),
            shouldopen=True,
            branches=action['info']['pkg_collection'].encode('utf-8'),
            poc=action['info']['pkg_poc'].encode('utf-8'),
            upstream_url=upstream,
            critpath=action['info']['pkg_critpath'],
            namespace=action['info']['pkg_namespace'],
            monitoring_status=monitoring_status,
            koschei=action['info'].get('koschei', False),
        )

        comaintainers = action['info'].get('co-maintainers')
        if comaintainers:
            for user in comaintainers.split(','):
                PKGDBCLIENT.update_acl(
                    action['info']['pkg_name'],
                    branches=action['info']['pkg_collection'],
                    acls=['commit', 'watchbugzilla', 'watchcommits'],
                    status='Approved',
                    user=user.strip(),
                    namespace=action['info']['pkg_namespace'],
                )

        approve_action(actionid)

        url = "{0}/package/{1}/{2}".format(
            PKGDBCLIENT.base_url,
            action['info'].get('pkg_namespace', 'rpms'),
            action['info']['pkg_name'])

        utils.comment_on_bug(
            bugid,
            'Package request has been approved: %s' % url
        )

    elif decision in ('deny', 'd'):
        data, message = deny_action(actionid)

        utils.comment_on_bug(
            bugid,
            'Package request has been denied with the reason: %s' % message
        )

    else:
        data = {
            'messages': ['Action {0} un-touched'.format(actionid)]
        }

    return data
Пример #5
0
def __handle_request_package(actionid, action):
    ''' Handle the new package requests. '''
    bugid = action['info']['pkg_review_url'].rsplit('/', 1)[1]
    if '=' in bugid:
        bugid = bugid.split('=', 1)[1]

    msgs = utils.check_package_creation(
        action['info'], bugid, PKGDBCLIENT, action['user'])

    bugid = utils.get_bug_id_from_url(action['info']['pkg_review_url'])

    decision = _ask_what_to_do(msgs)
    if decision in ('a', 'approve'):
        desc = action['info'].get('pkg_description', None)
        if desc:
            desc = desc.encode('utf-8')
        upstream = action['info'].get('pkg_upstream_url', None)
        if upstream:
            upstream = upstream.encode('utf-8')

        monitoring_status = action['info'].get('monitoring_status', True)
        # If we get an invalid monitoring status, use the default
        if str(monitoring_status) not in ['True', 'False', 'nobuild']:
            monitoring_status = True

        data = PKGDBCLIENT.create_package(
            pkgname=action['info']['pkg_name'].encode('utf-8'),
            summary=action['info']['pkg_summary'].encode('utf-8'),
            description=desc,
            review_url=action['info']['pkg_review_url'].encode('utf-8'),
            status=action['info']['pkg_status'].encode('utf-8'),
            shouldopen=True,
            branches=action['info']['pkg_collection'].encode('utf-8'),
            poc=action['info']['pkg_poc'].encode('utf-8'),
            upstream_url=upstream,
            critpath=action['info']['pkg_critpath'],
            namespace=action['info']['pkg_namespace'],
            monitoring_status=monitoring_status,
            koschei=action['info'].get('koschei', False),
        )

        comaintainers = action['info'].get('co-maintainers')
        if comaintainers:
            for user in comaintainers.split(','):
                PKGDBCLIENT.update_acl(
                    action['info']['pkg_name'],
                    branches=action['info']['pkg_collection'],
                    acls=['commit', 'watchbugzilla', 'watchcommits'],
                    status='Approved',
                    user=user.strip(),
                    namespace=action['info']['pkg_namespace'],
                )

        approve_action(actionid)

        url = "{0}/package/{1}/{2}".format(
            PKGDBCLIENT.base_url,
            action['info'].get('pkg_namespace', 'rpms'),
            action['info']['pkg_name'])

        utils.comment_on_bug(
            bugid,
            'Package request has been approved: %s' % url
        )

    elif decision in ('deny', 'd'):
        data, message = deny_action(actionid)

        utils.comment_on_bug(
            bugid,
            'Package request has been denied with the reason: %s' % message
        )

    else:
        data = {
            'messages': ['Action {0} un-touched'.format(actionid)]
        }

    return data