def default(self, search, *args, **kw): results = set() search = search.strip() # Search name-version-release map(results.add, PackageUpdate.select( LIKE(PackageUpdate.q.title, '%%%s%%' % search), orderBy=PackageUpdate.q.date_submitted)) # Search bug numbers try: map(lambda bug: map(results.add, bug.updates), Bugzilla.select(Bugzilla.q.bz_id==int(search))) except ValueError: # can't convert search search to integer pass # Search CVEs if search.startswith('CVE') or search.startswith('CAN'): # Search bug titles for CVE, since that is how we track them now map(lambda bug: map(results.add, bug.updates), Bugzilla.select(LIKE(Bugzilla.q.title, '%%%s%%' % search))) # We still have some CVE objects lying around, so search them too map(lambda cve: map(results.add, cve.updates), CVE.select(CVE.q.cve_id==search)) # If there is only 1 result, then jump right to it num_items = len(results) if len(results) == 1: raise redirect(results.pop().get_url()) return dict(updates=list(results), num_items=num_items, title="%d Results Found" % num_items)
def fix_bug_titles(): """ Go through all bugs with invalid titles and see if we can re-fetch them. If bugzilla is down, then bodhi simply replaces the title with 'Unable to fetch bug title' or 'Invalid bug number'. So lets occasionally see if we can re-fetch those bugs. """ from bodhi.model import Bugzilla from sqlobject.sqlbuilder import OR log.debug("Running fix_bug_titles job") for bug in Bugzilla.select( OR(Bugzilla.q.title == 'Invalid bug number', Bugzilla.q.title == 'Unable to fetch bug title')): bug.fetch_details()
def default(self, search, *args, **kw): results = set() search = search.strip() # Search name-version-release map( results.add, PackageUpdate.select(LIKE(PackageUpdate.q.title, '%%%s%%' % search), orderBy=PackageUpdate.q.date_submitted)) # Search bug numbers try: map(lambda bug: map(results.add, bug.updates), Bugzilla.select(Bugzilla.q.bz_id == int(search))) except ValueError: # can't convert search search to integer pass # Search CVEs if search.startswith('CVE') or search.startswith('CAN'): # Search bug titles for CVE, since that is how we track them now map(lambda bug: map(results.add, bug.updates), Bugzilla.select(LIKE(Bugzilla.q.title, '%%%s%%' % search))) # We still have some CVE objects lying around, so search them too map(lambda cve: map(results.add, cve.updates), CVE.select(CVE.q.cve_id == search)) # If there is only 1 result, then jump right to it num_items = len(results) if len(results) == 1: raise redirect(results.pop().get_url()) return dict(updates=list(results), num_items=num_items, title="%d Results Found" % num_items)