示例#1
0
class UpdatePromoter(object):
    def __init__(self, dry_run=False):
        self._client = BodhiClient()
        self._client.init_username()
        self._dry_run = dry_run
        self._log_prefix = ''
        if dry_run:
            self._log_prefix = 'dry run: '

    def promote_update(self, update, status='stable'):
        print('{}{} - requesting {}'.format(self._log_prefix, update.title,
                                            status))
        request_params = {
            'update': update.alias,
            'request': status,
        }
        if not self._dry_run:
            self._client.request(**request_params)

    def promote_updates(self, updates, status='stable'):
        for update in updates:
            if status in ['stable', 'batched'
                          ] and not update.meets_testing_requirements:
                print('{}skipping {} - not eligible for {}'.format(
                    self._log_prefix, update.title, status))
                continue
            if update.request == status:
                continue
            self.promote_update(update, status)

    def get_updates(self, release, package=None, status='testing'):
        query_params = {
            'mine': True,
            'releases': release,
            'rows_per_page': 100,
            'status': status,
        }
        if package:
            query_params['packages'] = package
        return self._client.query(**query_params).updates
示例#2
0
    def push_bodhi_update(update_alias: str):
        from bodhi.client.bindings import BodhiClient, UpdateNotFound

        b = BodhiClient()
        try:
            response = b.request(update=update_alias, request="stable")
            logger.debug(f"Bodhi response:\n{response}")
            logger.info(f"Bodhi update {response['alias']} pushed to stable:\n"
                        f"- {response['url']}\n"
                        f"- stable_karma: {response['stable_karma']}\n"
                        f"- unstable_karma: {response['unstable_karma']}\n"
                        f"- notes:\n{response['notes']}\n")
        except UpdateNotFound:
            logger.error("Update was not found.")