| OLD | NEW |
| (Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright 2017 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 from __future__ import print_function |
| 7 |
| 8 |
| 9 import argparse |
| 10 import json |
| 11 import os |
| 12 import sys |
| 13 import urllib2 |
| 14 |
| 15 |
| 16 def main(argv): |
| 17 parser = argparse.ArgumentParser() |
| 18 parser.add_argument('issue', action='store', type=int) |
| 19 args = parser.parse_args(argv) |
| 20 |
| 21 try: |
| 22 for approver in rietveld_approvers_for_issue(args.issue): |
| 23 print(approver) |
| 24 return 0 |
| 25 except Exception as e: |
| 26 print('Exception raised: %s' % str(e), file=sys.stderr) |
| 27 return 1 |
| 28 |
| 29 |
| 30 def rietveld_approvers_for_issue(issue): |
| 31 """Returns a sorted list of the approves for a given Rietveld issue.""" |
| 32 |
| 33 url = 'https://codereview.chromium.org/api/%d?messages=true' % issue |
| 34 fp = None |
| 35 try: |
| 36 fp = urllib2.urlopen(url) |
| 37 issue_props = json.load(fp) |
| 38 messages = issue_props.get('messages', []) |
| 39 return sorted(set(m['sender'] for m in messages if m.get('approval'))) |
| 40 finally: |
| 41 if fp: |
| 42 fp.close() |
| 43 |
| 44 |
| 45 if __name__ == '__main__': |
| 46 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |