def request_age_wait(self,
                         age_min=None,
                         request=None,
                         target_project=None):
        if not request:
            request = self.request

        if not target_project:
            target_project = self.action.tgt_project

        if age_min is None or isinstance(age_min, str):
            key = self.request_age_min_key if age_min is None else age_min
            age_min = int(
                Config.get(self.apiurl,
                           target_project).get(key,
                                               self.request_age_min_default))

        age = request_age(request).total_seconds()
        if age < age_min:
            self.logger.info(
                'skipping {} of age {:.2f}s since it is younger than {}s'.
                format(request.reqid, age, age_min))
            return True

        return False
def requests(args):
    apiurl = osc.conf.config['apiurl']
    devel_projects = devel_projects_load(args)

    # Disable including source project in get_request_list() query.
    osc.conf.config['include_request_from_project'] = False
    for devel_project in devel_projects:
        requests = get_request_list(apiurl,
                                    devel_project,
                                    req_state=('new', 'review'),
                                    req_type='submit',
                                    withfullhistory=True)
        for request in requests:
            action = request.actions[0]
            age = request_age(request).days
            if age < args.min_age:
                continue

            print(' '.join((
                request.reqid,
                '/'.join((action.tgt_project, action.tgt_package)),
                '/'.join((action.src_project, action.src_package)),
                '({} days old)'.format(age),
            )))

            if args.remind:
                remind_comment(apiurl, args.repeat_age, request.reqid,
                               action.tgt_project, action.tgt_package)
def reviews(args):
    apiurl = osc.conf.config['apiurl']
    devel_projects = devel_projects_load(args)

    for devel_project in devel_projects:
        requests = get_review_list(apiurl, byproject=devel_project)
        for request in requests:
            action = request.actions[0]
            if action.type != 'submit':
                continue

            age = request_age(request).days
            if age < args.min_age:
                continue

            for review in request.reviews:
                if review.by_project == devel_project:
                    break

            print(' '.join((
                request.reqid,
                '/'.join((review.by_project, review.by_package))
                if review.by_package else review.by_project,
                '/'.join((action.tgt_project, action.tgt_package)),
                '({} days old)'.format(age),
            )))

            if args.remind:
                remind_comment(apiurl, args.repeat_age, request.reqid,
                               review.by_project, review.by_package)
    def supplement(self, request):
        """ Provide additional information for grouping """
        if request.get('ignored'):
            # Only supplement once.
            return

        history = request.find('history')
        if history is not None:
            age = request_age(request).total_seconds()
            request.set('aged', str(age >= self.request_age_threshold))

        request_type = request.find('./action').get('type')
        target = request.find('./action/target')
        target_project = target.get('project')
        target_package = target.get('package')
        devel, _ = devel_project_fallback(self.api.apiurl, target_project,
                                          target_package)
        if not devel and request_type == 'submit':
            devel = request.find('./action/source').get('project')
        if devel:
            target.set('devel_project', devel)
            StrategySuper.supplement(request)

        ring = self.ring_get(target_package)
        if ring:
            target.set('ring', ring)

        request_id = int(request.get('id'))
        if request_id in self.requests_ignored:
            request.set('ignored', str(self.requests_ignored[request_id]))
        else:
            request.set('ignored', 'False')

        request.set('postponed', 'False')
Exemple #5
0
def reviews(args):
    apiurl = osc.conf.config['apiurl']
    devel_projects = devel_projects_load(args)

    for devel_project in devel_projects:
        requests = get_review_list(apiurl, byproject=devel_project)
        for request in requests:
            action = request.actions[0]
            if action.type != 'submit':
                continue

            age = request_age(request).days
            if age < args.min_age:
                continue

            for review in request.reviews:
                if review.by_project == devel_project:
                    break

            print(' '.join((
                request.reqid,
                '/'.join((review.by_project, review.by_package)) if review.by_package else review.by_project,
                '/'.join((action.tgt_project, action.tgt_package)),
                '({} days old)'.format(age),
            )))

            if args.remind:
                remind_comment(apiurl, args.repeat_age, request.reqid, review.by_project, review.by_package)
Exemple #6
0
def requests(args):
    apiurl = osc.conf.config['apiurl']
    devel_projects = devel_projects_load(args)

    # Disable including source project in get_request_list() query.
    osc.conf.config['include_request_from_project'] = False
    for devel_project in devel_projects:
        requests = get_request_list(apiurl, devel_project,
                                    req_state=('new', 'review'),
                                    req_type='submit',
                                    withfullhistory=True)
        for request in requests:
            action = request.actions[0]
            age = request_age(request).days
            if age < args.min_age:
                continue

            print(' '.join((
                request.reqid,
                '/'.join((action.tgt_project, action.tgt_package)),
                '/'.join((action.src_project, action.src_package)),
                '({} days old)'.format(age),
            )))

            if args.remind:
                remind_comment(apiurl, args.repeat_age, request.reqid, action.tgt_project, action.tgt_package)
def requests(args):
    apiurl = osc.conf.config['apiurl']
    devel_projects = devel_projects_load(args)

    for devel_project in devel_projects:
        requests = get_request_list(
            apiurl,
            devel_project,
            req_state=('new', 'review'),
            req_type='submit',
            # Seems to work backwards, as it includes only.
            exclude_target_projects=[devel_project],
            withfullhistory=True)
        for request in requests:
            action = request.actions[0]
            age = request_age(request).days
            if age < args.min_age:
                continue

            print(' '.join((
                request.reqid,
                '/'.join((action.tgt_project, action.tgt_package)),
                '/'.join((action.src_project, action.src_package)),
                '({} days old)'.format(age),
            )))

            if args.remind:
                remind_comment(apiurl, args.repeat_age, request.reqid,
                               action.tgt_project, action.tgt_package)
    def supplement(self, request):
        """ Provide additional information for grouping """
        if request.get('ignored'):
            # Only supplement once.
            return

        history = request.find('history')
        if history is not None:
            age = request_age(request).total_seconds()
            request.set('aged', str(age >= self.request_age_threshold))

        request_type = request.find('./action').get('type')
        target = request.find('./action/target')
        target_project = target.get('project')
        target_package = target.get('package')
        devel, _ = devel_project_fallback(self.api.apiurl, target_project, target_package)
        if not devel and request_type == 'submit':
            devel = request.find('./action/source').get('project')
        if devel:
            target.set('devel_project', devel)
            StrategySuper.supplement(request)

        if target_project == self.api.cnonfree:
            target.set('nonfree', 'nonfree')

        ring = self.ring_get(target_package)
        if ring:
            target.set('ring', ring)
        elif not self.api.conlyadi and request_type == 'delete':
            # Delete requests should always be considered in a ring.
            target.set('ring', 'delete')

        request_id = int(request.get('id'))
        if request_id in self.requests_ignored:
            request.set('ignored', str(self.requests_ignored[request_id]))
        else:
            request.set('ignored', 'False')

        request.set('postponed', 'False')
Exemple #9
0
def check(apiurl,
          entity,
          entity_type='group',
          comment=False,
          bot=None,
          threshold=2 * 3600,
          threshold_require=True):
    queries = {'request': {'limit': 1000, 'withfullhistory': 1}}
    xpath = 'state[@name="new"] or state[@name="review"]'

    if entity == 'staging-bot':
        xpath = xpath_join(
            xpath,
            'review[starts-with(@by_project, "openSUSE:") and @state="new"]',
            op='and')
        xpath = xpath_join(xpath, 'history/@who="{}"'.format(entity), op='and')

        requests = search(apiurl, queries, request=xpath)['request']
        for request in requests:
            age = request_age(request).total_seconds()
            request_debug(request, age, threshold)

            if age <= threshold:
                return True

        return False

    xpath = xpath_join(xpath,
                       'review[@by_{}="{}" and @state="new"]'.format(
                           entity_type, entity),
                       op='and')
    requests = search(apiurl, queries, request=xpath)['request']

    print_debug('{:,} requests'.format(len(requests)))
    if not len(requests):
        # Could check to see that a review has been performed in the last week.
        return True

    all_comment = True
    for request in requests:
        kwargs = {}
        if comment == 'project':
            # Would be a lot easier with lxml, but short of reparsing or monkey.
            for review in request.findall('review[@by_project]'):
                if review.get('by_project').startswith('openSUSE:'):
                    kwargs['project_name'] = review.get('by_project')
            # TODO repo-checker will miss stagings where delete only problem so
            # comment on request, but should be fixed by #1084.
        elif comment:
            kwargs['request_id'] = request.get('id')

        age = request_age(request).total_seconds()
        request_debug(request, age, threshold)
        comment_age = check_comment(apiurl, bot, **kwargs)
        if comment_age:
            if comment_age <= threshold:
                print_debug('comment found below threshold')
                return True
        elif age > threshold:
            print_debug('no comment found and above threshold')
            all_comment = False
            if threshold_require:
                return False
            else:
                continue
        else:
            print_debug('no comment found, but below threshold')

    print_debug('all comments: {}'.format(all_comment))
    return all_comment
def check(apiurl, entity, entity_type='group', comment=False, bot=None,
          threshold=2 * 3600, threshold_require=True):
    queries = {'request': {'limit': 1000, 'withfullhistory': 1}}
    xpath = 'state[@name="new"] or state[@name="review"]'

    if entity == 'staging-bot':
        xpath = xpath_join(
            xpath, 'review[starts-with(@by_project, "openSUSE:") and @state="new"]', op='and')
        xpath = xpath_join(
            xpath, 'history/@who="{}"'.format(entity), op='and')

        requests = search(apiurl, queries, request=xpath)['request']
        for request in requests:
            age = request_age(request).total_seconds()
            request_debug(request, age, threshold)

            if age <= threshold:
                return True

        return False

    xpath = xpath_join(
        xpath, 'review[@by_{}="{}" and @state="new"]'.format(entity_type, entity), op='and')
    requests = search(apiurl, queries, request=xpath)['request']

    print_debug('{:,} requests'.format(len(requests)))
    if not len(requests):
        # Could check to see that a review has been performed in the last week.
        return True

    all_comment = True
    for request in requests:
        kwargs = {}
        if comment == 'project':
            # Would be a lot easier with lxml, but short of reparsing or monkey.
            for review in request.findall('review[@by_project]'):
                if review.get('by_project').startswith('openSUSE:'):
                    kwargs['project_name'] = review.get('by_project')
            # TODO repo-checker will miss stagings where delete only problem so
            # comment on request, but should be fixed by #1084.
        elif comment:
            kwargs['request_id'] = request.get('id')

        age = request_age(request).total_seconds()
        request_debug(request, age, threshold)
        comment_age = check_comment(apiurl, bot, **kwargs)
        if comment_age:
            if comment_age <= threshold:
                print_debug('comment found below threshold')
                return True
        elif age > threshold:
            print_debug('no comment found and above threshold')
            all_comment = False
            if threshold_require:
                return False
            else:
                continue
        else:
            print_debug('no comment found, but below threshold')

    print_debug('all comments: {}'.format(all_comment))
    return all_comment