コード例 #1
0
ファイル: cli.py プロジェクト: yarda/bodhi
def comment(update, text, karma, user, password, **kwargs):
    client = Bodhi2Client(username=user,
                          password=password,
                          staging=kwargs['staging'])
    print('%r %r %r' % (update, text, karma))
    resp = client.comment(update, text, karma)
    print_resp(resp, client)
コード例 #2
0
def edit(username, password, **kwargs):
    client = Bodhi2Client(username=username, password=password)
    csrf = client.csrf()

    edited = kwargs.pop('name')

    if edited is None:
        print("ERROR: Please specify the name of the release to edit")
        return

    res = client.send_request('releases/%s' % edited, verb='GET', auth=True)

    data = munch.unmunchify(res)

    if 'errors' in data:
        print_errors(data)

    data['edited'] = edited
    data['csrf_token'] = csrf

    new_name = kwargs.pop('new_name')

    if new_name is not None:
        data['name'] = new_name

    for k, v in kwargs.items():
        if v is not None:
            data[k] = v

    save(client, **data)
コード例 #3
0
ファイル: cli.py プロジェクト: yarda/bodhi
def new(user, password, **kwargs):
    client = Bodhi2Client(username=user,
                          password=password,
                          staging=kwargs['staging'])

    if kwargs['file'] is None:
        updates = [kwargs]

    else:
        updates = client.parse_file(os.path.abspath(kwargs['file']))

    if kwargs['notes_file'] is not None:
        if kwargs['notes'] is None:
            with open(kwargs['notes_file'], 'r') as fin:
                kwargs['notes'] = fin.read()

        else:
            click.echo("ERROR: Cannot specify --notes and --notes-file")
            sys.exit(1)

    for update in updates:
        try:
            resp = client.save(**update)
            print_resp(resp, client)
        except BodhiClientException as e:
            click.echo(str(e))
        except Exception as e:
            traceback.print_exc()
コード例 #4
0
def info(name):
    client = Bodhi2Client()

    res = client.send_request('releases/%s' % name, verb='GET', auth=False)

    if 'errors' in res:
        print_errors(res)

    else:
        print('Release:')
        print_release(res)
コード例 #5
0
ファイル: cli.py プロジェクト: yarda/bodhi
def download(**kwargs):
    client = Bodhi2Client(staging=kwargs['staging'])
    del (kwargs['staging'])
    # At this point we need to have reduced the kwargs dict to only our
    # query options (cves, updateid, builds)
    if not any(kwargs.values()):
        click.echo(
            "ERROR: must specify at least one of --cves, --updateid, --builds")
        sys.exit(1)

    # As the query method doesn't let us construct OR queries, we're
    # gonna run one query for each option that was passed. The syntax
    # for this is a bit ugly, sorry.
    for (attr, value) in kwargs.items():
        if value:
            expecteds = len(value.split(','))
            resp = client.query(**{attr: value})
            if len(resp.updates) == 0:
                click.echo("WARNING: No {0} found!".format(attr))
            elif len(resp.updates) < expecteds:
                click.echo("WARNING: Some {0} not found!".format(attr))
            # Not sure if we need a check for > expecteds, I don't
            # *think* that should ever be possible for these opts.

            for update in resp.updates:
                click.echo("Downloading packages from {0}".format(
                    update['title']))
                for build in update['builds']:
                    # subprocess is icky, but koji module doesn't
                    # expose this in any usable way, and we don't want
                    # to rewrite it here.
                    args = ('koji', 'download-build', '--arch=noarch',
                            '--arch={0}'.format(platform.machine()),
                            build['nvr'])
                    ret = subprocess.call(args)
                    if ret:
                        click.echo("WARNING: download of {0} failed!".format(
                            build['nvr']))
コード例 #6
0
print('%r total' % result.total)
while result.page < result.pages:
    print('Querying page %d out of %d' % (result.page + 1, pages))
    result = bodhi.query(page=result.page + 1, **query)
    updates.extend(result.updates)

print('Fetched %d updates total' % len(updates))
assert len(updates) == total, len(updates)

print('Querying for my updates')
result = bodhi.query(mine=True)
print(result)
assert result.updates[0].user.name == username, result.updates[0].user.name

print('Testing the Bodhi2Client(staging=True) directly')
bodhi = Bodhi2Client(staging=True, username=username, password=password)
try:
    result = bodhi.save(
        builds=build,
        type='bugfix',
        notes='The quick brown fox jumped over the lazy dog',
    )
    print(result)
except BodhiClientException as e:
    print(e)

result = bodhi.query(builds='qt-creator-3.4.1-3.fc23')
updates = result['updates']
update = updates[0]
assert len(updates) == 1, len(updates)
コード例 #7
0
def push(username, password, cert_prefix, **kwargs):
    staging = kwargs.pop('staging')
    resume = kwargs.pop('resume')
    client = Bodhi2Client(username=username,
                          password=password,
                          staging=staging)

    # Don't try and push locked updates
    kwargs['locked'] = False

    # If we're resuming a push
    if resume:
        updates = []
        if staging:
            locks = '/var/cache/bodhi/mashing/MASHING-*'
        else:
            locks = '/mnt/koji/mash/updates/MASHING-*'
        for lockfile in glob.glob(locks):
            doit = raw_input('Resume %s? (y/n)' % lockfile).strip().lower()
            if doit == 'n':
                continue

            with file(lockfile) as lock:
                state = json.load(lock)

            click.echo(lockfile)
            for update in state['updates']:
                updates.append(update)
                click.echo(update)
    else:
        # release->request->updates
        releases = defaultdict(lambda: defaultdict(list))
        updates = []

        # Gather the list of updates based on the query parameters
        # Since there's currently no simple way to get a list of all updates with
        # any request, we'll take a comma/space-delimited list of them and query
        # one at a time.
        requests = kwargs['request'].replace(',', ' ').split(' ')
        del (kwargs['request'])
        for request in requests:
            resp = client.query(request=request, **kwargs)
            for update in resp.updates:
                updates.append(update.title)
                for build in update.builds:
                    releases[update.release.name][request].append(build.nvr)
            while resp.page < resp.pages:
                resp = client.query(request=request,
                                    page=resp.page + 1,
                                    **kwargs)
                for update in resp.updates:
                    updates.append(update.title)
                    for build in update.builds:
                        releases[update.release.name][request].append(
                            build.nvr)

            # Write out a file that releng uses to pass to sigul for signing
            # TODO: in the future we should integrate signing into the workflow
            for release in releases:
                output_filename = request.title() + '-' + release
                click.echo(output_filename + '\n==========')
                with file(output_filename, 'w') as out:
                    for build in releases[release][request]:
                        out.write(build + '\n')
                        click.echo(build)
                click.echo('')

    doit = raw_input('Push these %d updates? (y/n)' %
                     len(updates)).lower().strip()
    if doit == 'y':
        click.echo('\nSending masher.start fedmsg')
        # Because we're a script, we want to send to the fedmsg-relay,
        # that's why we say active=True
        bodhi.notifications.init(active=True, cert_prefix=cert_prefix)
        bodhi.notifications.publish(
            topic='masher.start',
            msg=dict(
                updates=list(updates),
                resume=resume,
                agent=username,
            ),
            force=True,
        )
    else:
        click.echo('\nAborting push')
コード例 #8
0
def create(username, password, **kwargs):
    client = Bodhi2Client(username=username, password=password)
    kwargs['csrf_token'] = client.csrf()

    save(client, **kwargs)
コード例 #9
0
 def __init__(self, environ, request):
     super(BodhiConnector, self).__init__(environ, request)
     self._prod_url = config.get('fedoracommunity.connector.bodhi.produrl',
                                 'https://bodhi.fedoraproject.org')
     self._bodhi_client = Bodhi2Client(self._base_url,
                                       insecure=self._insecure)
コード例 #10
0
ファイル: cli.py プロジェクト: yarda/bodhi
def save_buildroot_overrides(nvr, duration, notes, user, password, staging):
    client = Bodhi2Client(username=user, password=password, staging=staging)
    resp = client.save_override(nvr=nvr, duration=duration, notes=notes)
    print_resp(resp, client)
コード例 #11
0
ファイル: cli.py プロジェクト: yarda/bodhi
def query_buildroot_overrides(user=None, **kwargs):
    client = Bodhi2Client(staging=kwargs['staging'])
    resp = client.list_overrides(user=user)
    print_resp(resp, client)
コード例 #12
0
ファイル: cli.py プロジェクト: yarda/bodhi
def request(update, state, user, password, **kwargs):
    client = Bodhi2Client(username=user,
                          password=password,
                          staging=kwargs['staging'])
    resp = client.request(update, state)
    print_resp(resp, client)
コード例 #13
0
ファイル: cli.py プロジェクト: yarda/bodhi
def query(**kwargs):
    client = Bodhi2Client(staging=kwargs['staging'])
    resp = client.query(**kwargs)
    print_resp(resp, client)