From 9a27a781a32638ceb78cb5f52d29d38650392dd2 Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Fri, 11 Sep 2015 19:59:34 -0400 Subject: [PATCH] Adds tool to collect and check new candidacies Change-Id: I0d91a7290dd678cf6e49139c5aed27713d4aac98 --- tools/check-new-candidacy.py | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 tools/check-new-candidacy.py diff --git a/tools/check-new-candidacy.py b/tools/check-new-candidacy.py new file mode 100755 index 00000000..600bc17f --- /dev/null +++ b/tools/check-new-candidacy.py @@ -0,0 +1,46 @@ +#!/bin/env python + +import subprocess +import json + + +def pread(argv): + return subprocess.Popen(argv, stdout=subprocess.PIPE).communicate()[0] + + +def execute(argv): + return subprocess.Popen(argv).wait() + + +def get_reviews(): + reviews = pread(["ssh", "-p", "29418", "review.openstack.org", "gerrit", + "query", "--format=JSON", "status:open", + "project:'openstack/election'"]).split('\n') + results = [] + for i in reviews: + if "status" not in i: + continue + review = json.loads(i) + if review['status'] == 'NEW': + results.append(int(review['number'])) + return results + + +def check_reviews(): + for review in get_reviews(): + if execute(["git", "review", "-d", "%d" % review]): + continue + print + fl = filter(lambda x: x.startswith("candidates/"), + pread(["git", "diff", "--name-only", "HEAD^"]).split('\n')) + if not len(fl): + print "[E] No candidacy added" + continue + for candidate in fl: + print "[->] https://review.openstack.org/%d - %s" % ( + review, candidate) + execute(["./tools/check-candidacy.py", candidate]) + execute(["git", "checkout", "master"]) + +if __name__ == "__main__": + check_reviews()