3 commits - bodhi/controllers.py
by Luke Macken
bodhi/controllers.py | 110 +++------------------------------------------------
1 file changed, 8 insertions(+), 102 deletions(-)
New commits:
commit 6e73a40aabd2f5e191ffcf712f8f75bf2f803b9e
Author: Luke Macken <lmacken(a)redhat.com>
Date: Sat Mar 21 21:18:49 2009 -0400
If we're listing stable updates, sort them by the date_pushed
diff --git a/bodhi/controllers.py b/bodhi/controllers.py
index 70451d3..1ea2a22 100644
--- a/bodhi/controllers.py
+++ b/bodhi/controllers.py
@@ -220,6 +220,8 @@ class Root(controllers.RootController):
query.append(PackageUpdate.q.releaseID == rel.id)
if status:
query.append(PackageUpdate.q.status == status)
+ if status == 'stable':
+ orderBy = PackageUpdate.q.date_pushed
if type_:
query.append(PackageUpdate.q.type == type_)
if mine:
commit 23f18862e0be32e0f716a47063e57e8f0786cb9d
Author: Luke Macken <lmacken(a)redhat.com>
Date: Sat Mar 21 21:17:07 2009 -0400
Remove the new group_updates and stringify 'list' parameters.
Doing this sort of logic in here makes this method extremely
inefficient. We ideally want to be returning a SelectResults
object that has yet to be iterated upon. This way, pagination
will be much more efficient.
diff --git a/bodhi/controllers.py b/bodhi/controllers.py
index c11ab10..70451d3 100644
--- a/bodhi/controllers.py
+++ b/bodhi/controllers.py
@@ -178,76 +178,6 @@ class Root(controllers.RootController):
identity.current.logout()
raise redirect('/')
- @expose(allow_json=True)
- @paginate('updates', limit=5, max_limit=20)
- @validate(validators={
- #'num_rows': validators.Int(),
- 'status': validators.UnicodeString(),
- 'type_': validators.UnicodeString(),
- 'username': validators.UnicodeString()
- })
- def query_updates(self, status=None, type_=None, username=None,
- release=None,
- #num_rows=5,
- order_by='date_submitted'):
- log.debug('query_updates(%s)' % locals())
- query = []
- packages = {}
- #done = False
- orderBy = PackageUpdate.q.date_submitted
-
- if order_by == 'date_pushed':
- orderBy = PackageUpdate.q.date_pushed
- if status:
- query.append(PackageUpdate.q.status == status)
- if type_:
- query.append(PackageUpdate.q.type == type_)
- if username:
- query.append(PackageUpdate.q.submitter == username)
- if release:
- rel = Release.byName(release.upper())
- query.append(PackageUpdate.q.releaseID == rel.id)
-
- updates = PackageUpdate.select(AND(*query), orderBy=orderBy,
- #limit=num_rows*2
- ).reversed()
-
- for update in updates:
- for build in update.builds:
- if build.package.name not in packages:
- #if len(packages) >= num_rows:
- # done = True
- # break
- packages[build.package.name] = {
- 'package_name' : build.package.name,
- 'dist_updates': []
- }
- else:
- skip = False
- for up in packages[build.package.name]['dist_updates']:
- if up['release'] == update.release.long_name:
- skip = True
- break
- if skip:
- break
- #if done:
- # break
- packages[build.package.name]['dist_updates'].append({
- 'release': update.release.long_name,
- 'version': '-'.join(build.nvr.split('-')[-2:])
- })
- packages[build.package.name]['dist_updates'][-1].update(
- dict(update._reprItems()))
- del(packages[build.package.name]['dist_updates'][-1]['releaseID'])
- #if done:
- # break
-
- results = {'updates': []}
- for package in packages:
- results['updates'].append(packages[package])
-
- return results
-
@expose(template="bodhi.templates.list", allow_json=True)
@paginate('updates', limit=20, max_limit=50, allow_limit_override=True)
@validate(validators={
@@ -258,14 +188,11 @@ class Root(controllers.RootController):
'type_': validators.UnicodeString(),
'package': validators.UnicodeString(),
'mine': validators.StringBool(),
- 'stringify': validators.StringBool(),
'get_auth': validators.StringBool(),
'username': validators.UnicodeString(),
- 'group_updates': validators.StringBool(),
})
def list(self, release=None, bugs=None, cves=None, status=None, type_=None,
- package=None, mine=False, stringify=False, get_auth=False,
- username=None, group_updates=False, **kw):
+ package=None, mine=False, get_auth=False, username=None, **kw):
""" Return a list of updates based on given parameters """
log.debug('list(%s)' % locals())
query = []
@@ -337,6 +264,10 @@ class Root(controllers.RootController):
except SQLObjectNotFound:
updates = []
+ # TODO: This filtering is extremely inefficient
+ # we should/could make these filters mutually exclusive, and
+ # simply make them queries
+
# Filter results by Bugs and/or CVEs
if bugs:
results = []
@@ -372,35 +303,8 @@ class Root(controllers.RootController):
results.append(dict_up)
updates = results
- if group_updates:
- packages = {}
- for update in updates:
- for build in update.builds:
- if build.package.name not in packages:
- packages[build.package.name] = {
- 'package_name' : build.package.name,
- 'dist_updates': []
- }
- else:
- skip = False
- for up in packages[build.package.name]['dist_updates']:
- if up['release'] == update.release.long_name:
- skip = True
- break
- if skip:
- break
- packages[build.package.name]['dist_updates'].append({
- 'release': update.release.long_name,
- 'version': '-'.join(build.nvr.split('-')[-2:])
- })
- packages[build.package.name]['dist_updates'][-1].update(
- dict(update.__json__()))
- del(packages[build.package.name]['dist_updates'][-1]['releaseID'])
- updates = [packages[pkg] for pkg in packages]
-
if isinstance(updates, list): num_items = len(updates)
else: num_items = updates.count()
- if stringify: updates = map(unicode, updates)
return dict(updates=updates, num_items=num_items,
title="%d %s found" % (num_items, num_items == 1 and
commit ab3f74f5e95cb502279632b78fa3f85adb9489b3
Author: Luke Macken <lmacken(a)redhat.com>
Date: Sat Mar 21 14:18:52 2009 -0400
Use update.__json__() instead of update._reprItems(), so we get the builds, etc.
diff --git a/bodhi/controllers.py b/bodhi/controllers.py
index 96a3cc1..c11ab10 100644
--- a/bodhi/controllers.py
+++ b/bodhi/controllers.py
@@ -367,7 +367,7 @@ class Root(controllers.RootController):
up.release.get_version())
if (identity.current.user_name in people[0]):
can_modify = True
- dict_up = dict(up._reprItems())
+ dict_up = up.__json__()
dict_up['can_modify'] = can_modify
results.append(dict_up)
updates = results
@@ -394,7 +394,7 @@ class Root(controllers.RootController):
'version': '-'.join(build.nvr.split('-')[-2:])
})
packages[build.package.name]['dist_updates'][-1].update(
- dict(update._reprItems()))
+ dict(update.__json__()))
del(packages[build.package.name]['dist_updates'][-1]['releaseID'])
updates = [packages[pkg] for pkg in packages]
15 years, 1 month
4 commits - bodhi/buildsys.py bodhi/masher.py bodhi/metadata.py
by Luke Macken
bodhi/buildsys.py | 20 ++++++++++++--------
bodhi/masher.py | 19 ++++++++++++++++---
bodhi/metadata.py | 2 --
3 files changed, 28 insertions(+), 13 deletions(-)
New commits:
commit e23a1bfc9d3a2381126d3b36ba65514e9906acfb
Author: Luke Macken <lmacken(a)redhat.com>
Date: Fri Mar 20 20:19:35 2009 -0400
Make our post-mash actions a bit more robust.
At one point or another, each one of these post-mash actions has exploded
somehow. This change makes it so that one bad update doesn't ruin things
for the rest of them. This will make various race-conditions less fatal.
diff --git a/bodhi/masher.py b/bodhi/masher.py
index dad5e38..492d059 100644
--- a/bodhi/masher.py
+++ b/bodhi/masher.py
@@ -606,10 +606,23 @@ class MashTask(Thread):
# Send out our notices/digest, update all bugs, and add comments
log.debug("Sending stable update notices and closing bugs")
for update in self.updates:
- update.modify_bugs()
- update.status_comment()
+ try:
+ update.modify_bugs()
+ except Exception, e:
+ log.error("There was a problem modifying the bugs for %s" % update.title)
+ log.exception(e)
+ try:
+ update.status_comment()
+ except Exception, e:
+ log.error("There was a problem updating the comment for %s" % update.title)
+ log.exception(e)
if update.status == 'stable':
- update.send_update_notice()
+ try:
+ update.send_update_notice()
+ except Exception, e:
+ log.error("There was a problem sending the notice for %s" % update.title)
+ log.exception(e)
+
log.debug("Sending updates-testing digests")
self.send_digest_mail()
commit 7f0ec1f875f881be172077d61fc36b9b74a52e92
Author: Luke Macken <lmacken(a)redhat.com>
Date: Fri Mar 20 20:17:46 2009 -0400
Hack around some weird issue that I can't figure out at the moment.
I really don't want to make this change, but for some reason the certs
are all ending up as None, even though the config.get should default to
the cert in the users home directory... Yet, this change made it work.
diff --git a/bodhi/buildsys.py b/bodhi/buildsys.py
index 6d365af..cc2d750 100644
--- a/bodhi/buildsys.py
+++ b/bodhi/buildsys.py
@@ -159,14 +159,17 @@ def koji_login(client=None, clientca=None, serverca=None):
Login to Koji and return the session
"""
if not client:
- client = config.get('client_cert',
- join(expanduser('~'), '.fedora.cert'))
+ client = config.get('client_cert')
+ if not client:
+ client = join(expanduser('~'), '.fedora.cert')
if not clientca:
- clientca = config.get('clientca_cert',
- join(expanduser('~'), '.fedora-upload-ca.cert'))
+ clientca = config.get('clientca_cert')
+ if not clientca:
+ clientca = join(expanduser('~'), '.fedora-upload-ca.cert')
if not serverca:
- serverca = config.get('serverca_cert',
- join(expanduser('~'), '.fedora-server-ca.cert'))
+ serverca = config.get('serverca_cert')
+ if not serverca:
+ serverca = join(expanduser('~'), '.fedora-server-ca.cert')
koji_session = koji.ClientSession(config.get('koji_hub'), {})
koji_session.ssl_login(client, clientca, serverca)
commit 1b4bbce4377bd53070831eb5510eafc8cf93cc89
Author: Luke Macken <lmacken(a)redhat.com>
Date: Fri Mar 20 20:13:10 2009 -0400
Don't be so verbose when adding updates to the updateinfo
diff --git a/bodhi/metadata.py b/bodhi/metadata.py
index d048a81..8eef7f8 100644
--- a/bodhi/metadata.py
+++ b/bodhi/metadata.py
@@ -172,8 +172,6 @@ class ExtendedMetadata:
log.debug("Update %s already in updateinfo" % update.title)
return
- log.debug("Generating extended metadata for %s" % update.title)
-
root = self._insert(self.doc.firstChild, 'update', attrs={
'type' : update.type,
'status' : update.status,
commit 9b405f38ec522e47f6aaa7bc08f6458a9ee69d4d
Author: Luke Macken <lmacken(a)redhat.com>
Date: Fri Mar 20 20:11:28 2009 -0400
Detect all failed tasks in our wait_for_tasks method
diff --git a/bodhi/buildsys.py b/bodhi/buildsys.py
index b1b8f78..6d365af 100644
--- a/bodhi/buildsys.py
+++ b/bodhi/buildsys.py
@@ -194,12 +194,13 @@ def wait_for_tasks(tasks, sleep=300):
to fail, otherwise zero.
"""
log.debug("Waiting for %d tasks to complete: %s" % (len(tasks), tasks))
+ failed_tasks = []
for task in tasks:
while not session.taskFinished(task):
time.sleep(sleep)
task_info = session.getTaskInfo(task)
if task_info['state'] != koji.TASK_STATES['CLOSED']:
log.error("Koji task %d failed" % task)
- return task
+ failed_tasks.append(task)
log.debug("Tasks completed successfully!")
- return 0
+ return failed_tasks
15 years, 1 month
bodhi/controllers.py
by Luke Macken
bodhi/controllers.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
New commits:
commit 20db5b7153c8ab95cfbb5d7d36c7eb1f61cb25b6
Author: Luke Macken <lmacken(a)redhat.com>
Date: Fri Mar 20 13:54:16 2009 -0400
Add a max_limit to our paginate decorators, like so:
@paginate('updates', limit=25, max_limit=20, allow_limit_override=True)
If `allow_limit_override` is specified, and not a `max_limit`, it will
ignore your `tg_paginate_limit`.
diff --git a/bodhi/controllers.py b/bodhi/controllers.py
index 2025ccd..96a3cc1 100644
--- a/bodhi/controllers.py
+++ b/bodhi/controllers.py
@@ -249,7 +249,7 @@ class Root(controllers.RootController):
return results
@expose(template="bodhi.templates.list", allow_json=True)
- @paginate('updates', limit=20, allow_limit_override=True)
+ @paginate('updates', limit=20, max_limit=50, allow_limit_override=True)
@validate(validators={
'release': validators.UnicodeString(),
'bugs': validators.UnicodeString(),
@@ -408,7 +408,7 @@ class Root(controllers.RootController):
@expose(template="bodhi.templates.mine", allow_json=True)
@identity.require(identity.not_anonymous())
- @paginate('updates', limit=20, allow_limit_override=True)
+ @paginate('updates', limit=20, max_limit=20, allow_limit_override=True)
def mine(self):
""" List all updates submitted by the current user """
updates = PackageUpdate.select(
@@ -864,7 +864,7 @@ class Root(controllers.RootController):
raise redirect(updates[0].get_url())
@expose(template='bodhi.templates.list')
- @paginate('updates', limit=20, allow_limit_override=True)
+ @paginate('updates', limit=20, max_limit=20, allow_limit_override=True)
def default(self, *args, **kw):
"""
This method allows for the following requests
@@ -1057,7 +1057,7 @@ class Root(controllers.RootController):
raise redirect('/')
@expose(template='bodhi.templates.comments')
- @paginate('comments', limit=20, allow_limit_override=True)
+ @paginate('comments', limit=20, max_limit=20, allow_limit_override=True)
def comments(self):
data = Comment.select(Comment.q.author != 'bodhi',
orderBy=Comment.q.timestamp).reversed()
@@ -1137,7 +1137,7 @@ class Root(controllers.RootController):
return dict(updates=updates)
@expose(template="bodhi.templates.user")
- @paginate('updates', limit=25, allow_limit_override=True)
+ @paginate('updates', limit=25, max_limit=20, allow_limit_override=True)
def user(self, username):
""" Return a list of updates submitted by a given person """
updates = PackageUpdate.select(PackageUpdate.q.submitter == username,
15 years, 1 month
2 commits - bodhi/controllers.py
by Luke Macken
bodhi/controllers.py | 41 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
New commits:
commit 1d04e9e1a2e290277d8051a267def7c06ba537f3
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Mar 19 18:22:30 2009 -0400
Add validators to our list method
diff --git a/bodhi/controllers.py b/bodhi/controllers.py
index 083aff8..2025ccd 100644
--- a/bodhi/controllers.py
+++ b/bodhi/controllers.py
@@ -250,6 +250,19 @@ class Root(controllers.RootController):
@expose(template="bodhi.templates.list", allow_json=True)
@paginate('updates', limit=20, allow_limit_override=True)
+ @validate(validators={
+ 'release': validators.UnicodeString(),
+ 'bugs': validators.UnicodeString(),
+ 'cves': validators.UnicodeString(),
+ 'status': validators.UnicodeString(),
+ 'type_': validators.UnicodeString(),
+ 'package': validators.UnicodeString(),
+ 'mine': validators.StringBool(),
+ 'stringify': validators.StringBool(),
+ 'get_auth': validators.StringBool(),
+ 'username': validators.UnicodeString(),
+ 'group_updates': validators.StringBool(),
+ })
def list(self, release=None, bugs=None, cves=None, status=None, type_=None,
package=None, mine=False, stringify=False, get_auth=False,
username=None, group_updates=False, **kw):
commit 161b46ecfe0f6de1f00882e907d57a924e931440
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Mar 19 18:22:13 2009 -0400
Add a group_updates parameter to our list method
diff --git a/bodhi/controllers.py b/bodhi/controllers.py
index faced31..083aff8 100644
--- a/bodhi/controllers.py
+++ b/bodhi/controllers.py
@@ -252,7 +252,7 @@ class Root(controllers.RootController):
@paginate('updates', limit=20, allow_limit_override=True)
def list(self, release=None, bugs=None, cves=None, status=None, type_=None,
package=None, mine=False, stringify=False, get_auth=False,
- username=None):
+ username=None, group_updates=False, **kw):
""" Return a list of updates based on given parameters """
log.debug('list(%s)' % locals())
query = []
@@ -359,6 +359,32 @@ class Root(controllers.RootController):
results.append(dict_up)
updates = results
+ if group_updates:
+ packages = {}
+ for update in updates:
+ for build in update.builds:
+ if build.package.name not in packages:
+ packages[build.package.name] = {
+ 'package_name' : build.package.name,
+ 'dist_updates': []
+ }
+ else:
+ skip = False
+ for up in packages[build.package.name]['dist_updates']:
+ if up['release'] == update.release.long_name:
+ skip = True
+ break
+ if skip:
+ break
+ packages[build.package.name]['dist_updates'].append({
+ 'release': update.release.long_name,
+ 'version': '-'.join(build.nvr.split('-')[-2:])
+ })
+ packages[build.package.name]['dist_updates'][-1].update(
+ dict(update._reprItems()))
+ del(packages[build.package.name]['dist_updates'][-1]['releaseID'])
+ updates = [packages[pkg] for pkg in packages]
+
if isinstance(updates, list): num_items = len(updates)
else: num_items = updates.count()
if stringify: updates = map(unicode, updates)
15 years, 1 month
bodhi/controllers.py
by Luke Macken
bodhi/controllers.py | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 70 insertions(+)
New commits:
commit 95a5fccb660f3fca82b143cd34511673122eb054
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Mar 19 17:29:03 2009 -0400
Add an initial query_updates JSON method (#297)
This method supports grouping of packages by release.
Note: it is reasonably fast when querying by a given user,
but without specifying, it will be extremely slow.
diff --git a/bodhi/controllers.py b/bodhi/controllers.py
index 6f244c3..faced31 100644
--- a/bodhi/controllers.py
+++ b/bodhi/controllers.py
@@ -178,6 +178,76 @@ class Root(controllers.RootController):
identity.current.logout()
raise redirect('/')
+ @expose(allow_json=True)
+ @paginate('updates', limit=5, max_limit=20)
+ @validate(validators={
+ #'num_rows': validators.Int(),
+ 'status': validators.UnicodeString(),
+ 'type_': validators.UnicodeString(),
+ 'username': validators.UnicodeString()
+ })
+ def query_updates(self, status=None, type_=None, username=None,
+ release=None,
+ #num_rows=5,
+ order_by='date_submitted'):
+ log.debug('query_updates(%s)' % locals())
+ query = []
+ packages = {}
+ #done = False
+ orderBy = PackageUpdate.q.date_submitted
+
+ if order_by == 'date_pushed':
+ orderBy = PackageUpdate.q.date_pushed
+ if status:
+ query.append(PackageUpdate.q.status == status)
+ if type_:
+ query.append(PackageUpdate.q.type == type_)
+ if username:
+ query.append(PackageUpdate.q.submitter == username)
+ if release:
+ rel = Release.byName(release.upper())
+ query.append(PackageUpdate.q.releaseID == rel.id)
+
+ updates = PackageUpdate.select(AND(*query), orderBy=orderBy,
+ #limit=num_rows*2
+ ).reversed()
+
+ for update in updates:
+ for build in update.builds:
+ if build.package.name not in packages:
+ #if len(packages) >= num_rows:
+ # done = True
+ # break
+ packages[build.package.name] = {
+ 'package_name' : build.package.name,
+ 'dist_updates': []
+ }
+ else:
+ skip = False
+ for up in packages[build.package.name]['dist_updates']:
+ if up['release'] == update.release.long_name:
+ skip = True
+ break
+ if skip:
+ break
+ #if done:
+ # break
+ packages[build.package.name]['dist_updates'].append({
+ 'release': update.release.long_name,
+ 'version': '-'.join(build.nvr.split('-')[-2:])
+ })
+ packages[build.package.name]['dist_updates'][-1].update(
+ dict(update._reprItems()))
+ del(packages[build.package.name]['dist_updates'][-1]['releaseID'])
+ #if done:
+ # break
+
+ results = {'updates': []}
+ for package in packages:
+ results['updates'].append(packages[package])
+
+ return results
+
@expose(template="bodhi.templates.list", allow_json=True)
@paginate('updates', limit=20, allow_limit_override=True)
def list(self, release=None, bugs=None, cves=None, status=None, type_=None,
15 years, 1 month
bodhi/controllers.py
by Luke Macken
bodhi/controllers.py | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
New commits:
commit d0478c546b8c42ab56f701916e613a38e4fecb60
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed Mar 4 16:32:23 2009 -0500
Don't assume that all of the builds are properly tagged when editing an update.
This should fix rel-eng#1309, and should hopefully cause a lot less problems
when editing updates.
diff --git a/bodhi/controllers.py b/bodhi/controllers.py
index d2f30ac..6f244c3 100644
--- a/bodhi/controllers.py
+++ b/bodhi/controllers.py
@@ -584,10 +584,7 @@ class Root(controllers.RootController):
valid = True
# If all of the builds are not properly tagged, then complain.
- # If we're editing an update, we can already assume that we've
- # moved the builds back to the candidates tag above, and can
- # skip this verification.
- if not valid and not edited:
+ if not valid:
flash_log("%s not tagged as an update candidate" % build)
raise InvalidUpdateException(params)
15 years, 1 month