From 8b6c0e594609e72e516b510bcbfc78c5f1251bcf Mon Sep 17 00:00:00 2001 From: Luke Macken Date: Feb 03 2016 17:19:06 +0000 Subject: utils: Bring some utils back to get tag2release working --- diff --git a/outhouse/handlers/atomic.py b/outhouse/handlers/atomic.py index e844e89..c6f0d67 100644 --- a/outhouse/handlers/atomic.py +++ b/outhouse/handlers/atomic.py @@ -31,11 +31,6 @@ class AtomicHandler(outhouse.handlers.BaseHandler): return 'bodhi.update.complete' in msg['topic'] def handle(self, pdc, msg): - """ - TODO: - - how do we want to handle batching of re-composing different artifacts - for example, after a push of updates, this will get called with each update - """ update = msg['msg']['update'] packages = [] for build in update['builds']: @@ -43,6 +38,8 @@ class AtomicHandler(outhouse.handlers.BaseHandler): # Convert 'Fedora 24' to 'fedora-24' release = update['release']['long_name'].lower().replace(' ', '-') + # We probably want to do this eventually, but since bodhi doesn't know about F24, it explodes + #release = outhouse.utils.tag2release(update['release']['stable_tag']) # TODO: queue them up for batch processing later # and we don't want to query pdc for each update fedmsg diff --git a/outhouse/utils.py b/outhouse/utils.py index 8239856..a67de9e 100644 --- a/outhouse/utils.py +++ b/outhouse/utils.py @@ -64,6 +64,28 @@ def handle_message(pdc, handlers, msg, verbose=False): raise +@cache.cache_on_arguments() +def bodhi_releases(): + # TODO -- get these releases from PDC, instead of from Bodhi + url = 'https://bodhi.fedoraproject.org/releases' + response = session.get(url, params=dict(rows_per_page=100)) + if not bool(response): + raise IOError('Failed to talk to %r: %r' % (url, response)) + return response.json()['releases'] + + +@cache.cache_on_arguments() +def rawhide_tag(): + # TODO - get this tag from PDC, instead of guessing from pkgdb + url = 'https://admin.fedoraproject.org/pkgdb/api/collections/' + response = session.get(url, params=dict(clt_status="Under Development")) + if not bool(response): + raise IOError('Failed to talk to %r: %r' % (url, response)) + collections = response.json()['collections'] + rawhide = [c for c in collections if c['koji_name'] == 'rawhide'][0] + return 'f' + rawhide['dist_tag'].strip('.fc') + + def tag2release(tag): if tag == rawhide_tag(): release = {