From 35bb428f958af31b3d8a8cf6226d44b7d819e164 Mon Sep 17 00:00:00 2001 From: Joe Gordon Date: Tue, 19 Nov 2013 21:38:59 -0800 Subject: [PATCH] Add launchpad support to check_success Make check_success query launchpad to provide more useful output. The goal is to make the output of check_success more useful by adding bug title, and affected projects etc. Change-Id: Ifd95056ade720be080cccf36196fad7bf4514ffd --- elastic_recheck/cmd/check_success.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/elastic_recheck/cmd/check_success.py b/elastic_recheck/cmd/check_success.py index 7e378620..040ca5fe 100755 --- a/elastic_recheck/cmd/check_success.py +++ b/elastic_recheck/cmd/check_success.py @@ -15,9 +15,14 @@ # under the License. import argparse +import os + +from launchpadlib import launchpad import elastic_recheck.elasticRecheck as er +LPCACHEDIR = os.path.expanduser('~/.launchpadlib/cache') + def get_options(): parser = argparse.ArgumentParser(description='Edit hiera yaml.') @@ -55,16 +60,31 @@ def collect_metrics(classifier): def print_metrics(data): print "Elastic recheck known issues" + print sorted_data = sorted(data.iteritems(), key=lambda x: -x[1]['fails']) for d in sorted_data: - print "Bug: %s => %s" % (d[0], d[1]['query'].rstrip()) + print "Bug: https://bugs.launchpad.net/bugs/%s => %s" % (d[0], d[1]['query'].rstrip()) + get_launchpad_bug(d[0]) + print "Hits" for s in d[1]['hits'].keys(): print " %s: %s" % (s, len(d[1]['hits'][s])) print +def get_launchpad_bug(bug): + lp = launchpad.Launchpad.login_anonymously('grabbing bugs', + 'production', + LPCACHEDIR) + lp_bug = lp.bugs[bug] + print "Title: %s" % lp_bug.title + targets = map(lambda x: (x.bug_target_name, x.status), lp_bug.bug_tasks) + print "Project: Status" + for target, status in targets: + print " %s: %s" % (target, status) + + def main(): opts = get_options() classifier = er.Classifier(opts.file)