From: Bill Erickson Date: Fri, 1 Jun 2012 17:25:39 +0000 (-0400) Subject: Launchpad digest script X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f96de33fc2cc8d8e5d250f7a45c140d170634c89;p=working%2Frandom.git Launchpad digest script Signed-off-by: Bill Erickson --- diff --git a/launchpad/lp_digest.py b/launchpad/lp_digest.py new file mode 100755 index 000000000..b8bfc0310 --- /dev/null +++ b/launchpad/lp_digest.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python +from launchpadlib.launchpad import Launchpad +from datetime import datetime, timedelta + +# XXX change to suit +cachedir = '/home/berick/.lpcache' + +# report on last 7 days +end_date = datetime.utcnow() +start_date = end_date - timedelta(days=7) + +launchpad = Launchpad.login_anonymously('testing', service_root="production") +project = launchpad.projects["evergreen"] + +tasks = project.searchTasks( + modified_since = start_date.strftime('%F'), + order_by = ['milestone', 'title'] +) + +new_bugs = [] +committed_bugs = [] + +for task in tasks: + bug = task.bug # avoid re-fetch + + if task.date_fix_committed: + if task.date_fix_committed.replace(tzinfo=None) > start_date: + committed_bugs.append({'task' : task, 'bug' : bug}) + + if bug.date_created.replace(tzinfo=None) > start_date: + new_bugs.append({'task' : task, 'bug' : bug}) + +last_milestone = None +def print_task(task_chunk): + global last_milestone + task = task_chunk['task'] + bug = task_chunk['bug'] + + milestone = '' + if task.milestone: + milestone = str(task.milestone).split('/')[-1:][0] + + if last_milestone is None or last_milestone != milestone: + last_milestone = milestone + print 'Milestone: %s' % milestone + print '---------\n' + + owner = bug.owner_link.split('~')[-1:][0] + + print '%s' % task.title.replace(' in Evergreen', '') + print '\timportance: %s; status: %s; comments: %d\n' % ( + task.importance, task.status, bug.message_count - 1) + +# ---------------------------------------------------------------- +# Print +# ---------------------------------------------------------------- + +print "Launchpad Evergreen Digest From %s to %s" % (start_date.strftime('%F'), end_date.strftime('%F')) +print "Tasks Committed: %d" % len(committed_bugs) +print "New Bugs: %d" % len(new_bugs) +print '' + +print '------------------------------------------' +print 'Committed Tasks:' +print '------------------------------------------' +print '' +for task_chunk in committed_bugs: print_task(task_chunk) + +last_milestone = None + +print '------------------------------------------' +print 'New Bugs:' +print '------------------------------------------' +print '' +for task_chunk in new_bugs: print_task(task_chunk) + + +