bodhi/masher.py | 8 +--
bodhi/overrides.py | 110 +++++++++++++++++++++++++++++++++++-------
bodhi/templates/overrides.kid | 6 +-
bodhi/tools/client.py | 28 ++++++++--
4 files changed, 124 insertions(+), 28 deletions(-)
New commits:
commit 15e99985a9b6501a85fefc1fc652fe8f0a068add
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed May 11 13:11:39 2011 -0400
Update the bodhi client to support override editing
diff --git a/bodhi/tools/client.py b/bodhi/tools/client.py
index 190c1c8..17e024c 100755
--- a/bodhi/tools/client.py
+++ b/bodhi/tools/client.py
@@ -100,12 +100,15 @@ def get_parser():
parser.add_option("", "--untested",
action="store_true",
help="Display a list of untested critical path updates",
dest="untested", default=False)
+
+ ## Buildroot Override Options
parser.add_option("-o", "--buildroot-override",
action="store",
help="Submit a build as a buildroot override",
dest="override", metavar="BUILD")
parser.add_option("--duration", action="store",
help="Duration of the buildroot override",
- dest="duration", metavar="DAYS")
+ dest="duration", metavar="DAYS",
+ default=3)
parser.add_option("-O", "--list-overrides",
action="store_true",
help="List all buildroot overrides",
dest="list_overrides")
@@ -118,6 +121,10 @@ def get_parser():
parser.add_option("--show-expired", action="store_true",
help="Show expired buildroot overrides",
dest="show_expired", default=False)
+ parser.add_option("--edit-override", action="store",
+ help="Edit override duration or notes",
+ dest="edit_override", default=None,
+ metavar="BUILD")
## Details
parser.add_option("-s", "--status", action="store",
type="string",
@@ -390,17 +397,23 @@ def main():
log.info(data['title'])
## Buildroot Overrides commands
- elif opts.override:
+ elif opts.override or opts.edit_override:
+ controller = 'override/save'
+ if opts.edit_override:
+ controller = 'override/save_edit_cli'
+ builds = opts.edit_override
+ else:
+ builds = opts.override
expiration = None
if opts.duration:
expiration = (datetime.utcnow() +
-
timedelta(days=int(opts.duration))).strftime('%m/%d/%Y')
+ timedelta(days=int(opts.duration))).strftime('%m/%d/%Y')
if opts.notes:
override_notes = opts.notes
- if not override_notes:
+ if not override_notes and not opts.edit_override:
override_notes = raw_input('Notes: ').strip()
- data = bodhi.send_request('override/save', req_params={
- 'builds': opts.override,
+ data = bodhi.send_request(controller, req_params={
+ 'builds': builds,
'notes': override_notes,
'expiration': expiration,
}, auth=True)
@@ -428,10 +441,13 @@ def main():
print " * Notes: %s" % override['notes']
print " * Submitter: %s" % override['submitter']
print " * Submitted: %s" %
override['date_submitted']
+ if override['expiration']:
+ print " * Expiration: %s" %
override['expiration']
if override['date_expired']:
print " * Expired: %s" %
override['date_expired']
print
+ ## Query updates
elif opts.status or opts.bugs or opts.release or opts.type_ or \
opts.mine or args:
def print_query(data):
commit 8693ea283771bac42324322ef2a1356d70d8e276
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed May 11 13:11:18 2011 -0400
Enhance our override list
diff --git a/bodhi/templates/overrides.kid b/bodhi/templates/overrides.kid
index e14c7b1..2aebb50 100644
--- a/bodhi/templates/overrides.kid
+++ b/bodhi/templates/overrides.kid
@@ -44,7 +44,7 @@
<?python row_color = "#FFFFFF" ?>
<tr class="list" bgcolor="${row_color}"
py:for="override in overrides">
<td class="list">
- ${override.build}
+ <a href="${tg.url('/override/edit?build=' +
override.build)}">${override.build}</a>
</td>
<td class="list">
${override.notes}
@@ -53,10 +53,10 @@
<a href="${tg.url('/user/' +
override.submitter)}">${override.submitter}</a>
</td>
<td class="list">
- ${override.date_submitted.strftime('%m/%d/%Y')}
+ ${override.date_submitted and
override.date_submitted.strftime('%m/%d/%Y') or ''}
</td>
<td class="list">
- ${override.expiration.strftime('%m/%d/%Y')}
+ ${override.expiration and
override.expiration.strftime('%m/%d/%Y') or ''}
</td>
<td class="list">
<div py:if="override.date_expired">
commit dfd155b6061b33173595c330d55bf9f5197e9443
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed May 11 13:10:58 2011 -0400
Add override editing functionality to the controller
diff --git a/bodhi/overrides.py b/bodhi/overrides.py
index 6d77950..82bb181 100644
--- a/bodhi/overrides.py
+++ b/bodhi/overrides.py
@@ -14,7 +14,7 @@
import logging
from datetime import datetime, timedelta
-from sqlobject import AND
+from sqlobject import AND, SQLObjectNotFound
from turbogears import (expose, paginate, validate, validators, redirect,
error_handler, url, flash, identity, config)
from turbogears.controllers import Controller
@@ -118,9 +118,11 @@ class BuildRootOverrideController(Controller):
log.debug(repr(locals()))
last_release = None # for our koji wait-repo example
- if not expiration:
- expiration = datetime.utcnow() + \
-
timedelta(days=config.get('buildroot_overrides.expire_after'))
+ if expiration:
+ if datetime.utcnow() > expiration:
+ flash('Cannot set an expiration in the past')
+ if request_format() == 'json': return dict()
+ raise redirect('/override/new')
try:
koji = get_session()
@@ -138,8 +140,7 @@ class BuildRootOverrideController(Controller):
people, groups = get_pkg_pushers(n)
if identity.current.user_name not in people[0]:
flash("Error: You do not have commit privileges to %s" % n)
- if request_format() == 'json':
- return dict()
+ if request_format() == 'json': return dict()
raise redirect('/override/new')
# Make sure the build is tagged correctly
@@ -147,8 +148,7 @@ class BuildRootOverrideController(Controller):
tags = [tag['name'] for tag in koji.listTags(build)]
except Exception, e:
flash(str(e))
- if request_format() == 'json':
- return dict()
+ if request_format() == 'json': return dict()
raise redirect('/override/new')
# Determine the release by the tag, and sanity check the builds
@@ -159,15 +159,13 @@ class BuildRootOverrideController(Controller):
elif tag in (rel.testing_tag, rel.stable_tag):
flash('Error: %s is already tagged with %s' % (
build, tag))
- if request_format() == 'json':
- return dict()
+ if request_format() == 'json': return dict()
raise redirect('/override/new')
if not release:
flash('Error: Could not determine release for %s with tags %s' %
(build, map(str, tags)))
- if request_format() == 'json':
- return dict()
+ if request_format() == 'json': return dict()
raise redirect('/override/new')
# Create a new overrides object
@@ -177,8 +175,7 @@ class BuildRootOverrideController(Controller):
expiration=expiration, releaseID=release.id)
except DuplicateEntryError:
flash('Error: buildroot override for %r already exists' % build)
- if request_format() == 'json':
- return dict()
+ if request_format() == 'json': return dict()
raise redirect('/override/new')
# Tag the build
@@ -189,6 +186,87 @@ class BuildRootOverrideController(Controller):
'You can wait for the new buildroot by running '
'`koji wait-repo %s-build`' % last_release.dist_tag)
- if request_format() == 'json':
- return dict(override.__json__())
+ if request_format() == 'json': return override.__json__()
+ raise redirect('/override')
+
+ @identity.require(identity.not_anonymous())
+ @expose(template="bodhi.templates.form")
+ def edit(self, build):
+ """ Edit an override """
+ try:
+ override = BuildRootOverride.byBuild(build)
+ except SQLObjectNotFound:
+ flash('Cannot find override %r' % build)
+ raise redirect('/override')
+ values = {
+ 'builds': {'text': override.build, 'hidden':
override.build},
+ 'expiration': override.expiration,
+ 'notes': override.notes,
+ 'edited': override.build,
+ }
+ if override.date_expired:
+ flash('This override is EXPIRED. Editing it will re-enable it')
+ return dict(form=override_form, values=values,
+ action=url("/override/save_edit"),
+ title='Edit Buildroot Override')
+
+ @identity.require(identity.not_anonymous())
+ @expose('json')
+ @validate(validators={
+ 'builds': validators.UnicodeString(),
+ 'notes': validators.UnicodeString(),
+ 'expiration': validators.DateTimeConverter(format='%m/%d/%Y',
+ not_empty=False)
+ })
+ @error_handler(new)
+ def save_edit_cli(self, builds, notes, expiration=None, **kw):
+ log.debug(repr(locals()))
+ if expiration:
+ if datetime.utcnow() > expiration:
+ flash('Cannot set an expiration in the past')
+ if request_format() == 'json': return dict()
+ raise redirect('/override/edit?build=' + builds)
+ try:
+ override = BuildRootOverride.byBuild(builds)
+ except SQLObjectNotFound:
+ flash('Cannot find override to edit %r' % builds)
+ raise redirect('/override')
+ override.notes = notes
+ override.expiration = expiration
+ if override.date_expired:
+ log.debug('Retagging expired override: %s' % override.build)
+ override.date_expired = None
+ override.tag()
+ flash('%s successfully edited' % builds)
+ if request_format() == 'json': return override.__json__()
+ raise redirect('/override')
+
+ @identity.require(identity.not_anonymous())
+ @expose('json')
+ @validate(form=override_form)
+ @error_handler(new)
+ def save_edit(self, builds, notes, expiration=None, **kw):
+ log.debug(repr(locals()))
+ if len(builds) > 1:
+ flash('Unable to add builds to an existing override')
+ raise redirect('/override')
+ builds = builds[0]
+ if expiration:
+ if datetime.utcnow() > expiration:
+ flash('Cannot set an expiration in the past')
+ if request_format() == 'json': return dict()
+ raise redirect('/override/edit?build=' + builds)
+ try:
+ override = BuildRootOverride.byBuild(builds)
+ except SQLObjectNotFound:
+ flash('Cannot find override to edit %r' % builds)
+ raise redirect('/override')
+ override.notes = notes
+ override.expiration = expiration
+ if override.date_expired:
+ log.debug('Retagging expired override: %s' % override.build)
+ override.date_expired = None
+ override.tag()
+ flash('%s successfully edited' % builds)
+ if request_format() == 'json': return override.__json__()
raise redirect('/override')
commit 4f2470a3753dea9ef15d1bd92134417001a1ee1c
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed May 11 13:10:28 2011 -0400
Automatically expire overrides when they hit stable, if they haven't already been
diff --git a/bodhi/masher.py b/bodhi/masher.py
index cc4553f..888d4b1 100644
--- a/bodhi/masher.py
+++ b/bodhi/masher.py
@@ -480,9 +480,11 @@ class MashTask(Thread):
for build in update.builds:
try:
override = BuildRootOverride.byBuild(build.nvr)
- log.info('Expiring buildroot override: %s' % build.nvr)
- override.untag()
- override.destroySelf()
+ if not override.date_expired:
+ log.info('Expiring buildroot override: %s' %
+ build.nvr)
+ override.untag()
+ override.destroySelf()
except SQLObjectNotFound:
pass