Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import argparse | 6 import argparse |
| 7 import datetime | 7 import datetime |
| 8 import json | 8 import json |
| 9 import logging | 9 import logging |
| 10 import sys | 10 import sys |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 def fetch_master_urls(gatekeeper, args): | 57 def fetch_master_urls(gatekeeper, args): |
| 58 # Currently using gatekeeper.json, but could use: | 58 # Currently using gatekeeper.json, but could use: |
| 59 # https://chrome-infra-stats.appspot.com/_ah/api#p/stats/v1/stats.masters.list | 59 # https://chrome-infra-stats.appspot.com/_ah/api#p/stats/v1/stats.masters.list |
| 60 master_urls = gatekeeper.keys() | 60 master_urls = gatekeeper.keys() |
| 61 if args.master_filter: | 61 if args.master_filter: |
| 62 master_urls = [url for url in master_urls if args.master_filter not in url] | 62 master_urls = [url for url in master_urls if args.master_filter not in url] |
| 63 return master_urls | 63 return master_urls |
| 64 | 64 |
| 65 | 65 |
| 66 def main(args): | 66 def main(args): |
| 67 logging.basicConfig(level=logging.DEBUG) | 67 logging.basicConfig(level=logging.CRITICAL) |
|
ghost stip (do not use)
2014/08/26 19:34:44
why not ERROR?
| |
| 68 | 68 |
| 69 parser = argparse.ArgumentParser() | 69 parser = argparse.ArgumentParser() |
| 70 parser.add_argument('data_url', action='store', nargs='*') | 70 parser.add_argument('data_url', action='store', nargs='*') |
| 71 parser.add_argument('--use-cache', action='store_true') | 71 parser.add_argument('--use-cache', action='store_true') |
| 72 parser.add_argument('--master-filter', action='store') | 72 parser.add_argument('--master-filter', action='store') |
| 73 parser.add_argument('--builder-filter', action='store') | 73 parser.add_argument('--builder-filter', action='store') |
| 74 args = parser.parse_args(args) | 74 args = parser.parse_args(args) |
| 75 | 75 |
| 76 if not args.data_url: | 76 if not args.data_url: |
| 77 logging.warn("No /data url passed, will write to builder_alerts.json") | 77 logging.warn("No /data url passed, will write to builder_alerts.json") |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 with open('builder_alerts.json', 'w') as f: | 124 with open('builder_alerts.json', 'w') as f: |
| 125 f.write(json.dumps(data, indent=1)) | 125 f.write(json.dumps(data, indent=1)) |
| 126 | 126 |
| 127 for url in args.data_url: | 127 for url in args.data_url: |
| 128 logging.info('POST %s alerts to %s' % (len(alerts), url)) | 128 logging.info('POST %s alerts to %s' % (len(alerts), url)) |
| 129 requests.post(url, data=data) | 129 requests.post(url, data=data) |
| 130 | 130 |
| 131 | 131 |
| 132 if __name__ == '__main__': | 132 if __name__ == '__main__': |
| 133 sys.exit(main(sys.argv[1:])) | 133 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |