Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 # Copyright (C) 2008 Evan Martin <martine@danga.com> | 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> |
| 7 | 7 |
| 8 """A git-command for integrating reviews on Rietveld.""" | 8 """A git-command for integrating reviews on Rietveld.""" |
| 9 | 9 |
| 10 from distutils.version import LooseVersion | 10 from distutils.version import LooseVersion |
| (...skipping 2213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2224 return 0 | 2224 return 0 |
| 2225 | 2225 |
| 2226 | 2226 |
| 2227 def CMDtry(parser, args): | 2227 def CMDtry(parser, args): |
| 2228 """Triggers a try job through Rietveld.""" | 2228 """Triggers a try job through Rietveld.""" |
| 2229 group = optparse.OptionGroup(parser, "Try job options") | 2229 group = optparse.OptionGroup(parser, "Try job options") |
| 2230 group.add_option( | 2230 group.add_option( |
| 2231 "-b", "--bot", action="append", | 2231 "-b", "--bot", action="append", |
| 2232 help=("IMPORTANT: specify ONE builder per --bot flag. Use it multiple " | 2232 help=("IMPORTANT: specify ONE builder per --bot flag. Use it multiple " |
| 2233 "times to specify multiple builders. ex: " | 2233 "times to specify multiple builders. ex: " |
| 2234 "'-bwin_rel:ui_tests,webkit_unit_tests -bwin_layout'. See " | 2234 "'-b win_rel:ui_tests,webkit_unit_tests -b win_layout'. See " |
| 2235 "the try server waterfall for the builders name and the tests " | 2235 "the try server waterfall for the builders name and the tests " |
| 2236 "available. Can also be used to specify gtest_filter, e.g. " | 2236 "available. Can also be used to specify gtest_filter, e.g. " |
| 2237 "-bwin_rel:base_unittests:ValuesTest.*Value")) | 2237 "-b win_rel:base_unittests:ValuesTest.*Value")) |
| 2238 group.add_option( | 2238 group.add_option( |
| 2239 "-m", "--master", default='', | 2239 "-m", "--master", default='', |
| 2240 help=("Specify a try master where to run the tries.")) | 2240 help=("Specify a try master where to run the tries.")) |
| 2241 group.add_option( | 2241 group.add_option( |
| 2242 "-r", "--revision", | 2242 "-r", "--revision", |
| 2243 help="Revision to use for the try job; default: the " | 2243 help="Revision to use for the try job; default: the " |
| 2244 "revision will be determined by the try server; see " | 2244 "revision will be determined by the try server; see " |
| 2245 "its waterfall for more info") | 2245 "its waterfall for more info") |
| 2246 group.add_option( | 2246 group.add_option( |
| 2247 "-c", "--clobber", action="store_true", default=False, | 2247 "-c", "--clobber", action="store_true", default=False, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 2269 parser.error('Need to upload first') | 2269 parser.error('Need to upload first') |
| 2270 | 2270 |
| 2271 props = cl.GetIssueProperties() | 2271 props = cl.GetIssueProperties() |
| 2272 if props.get('private'): | 2272 if props.get('private'): |
| 2273 parser.error('Cannot use trybots with private issue') | 2273 parser.error('Cannot use trybots with private issue') |
| 2274 | 2274 |
| 2275 if not options.name: | 2275 if not options.name: |
| 2276 options.name = cl.GetBranch() | 2276 options.name = cl.GetBranch() |
| 2277 | 2277 |
| 2278 if options.bot and not options.master: | 2278 if options.bot and not options.master: |
| 2279 parser.error('For manually specified bots please also specify the ' | 2279 err_msg = '' |
| 2280 'tryserver master, e.g. "-m tryserver.chromium.linux".') | 2280 map_url = 'http://builders-map.appspot.com/' |
|
Paweł Hajdan Jr.
2014/08/08 11:13:50
This should use HTTPS.
sheyang
2014/08/11 19:30:06
Done.
| |
| 2281 try: | |
| 2282 res = urllib2.urlopen(map_url) | |
| 2283 master_map = json.load(res) | |
| 2284 except urllib2.URLError as url_e: | |
| 2285 err_msg = ('Fail to fetch builder-to-master map from %s. Error: %s.' % | |
|
Paweł Hajdan Jr.
2014/08/08 11:13:50
nit: Fail -> Failed
sheyang
2014/08/11 19:30:05
Done.
| |
| 2286 (map_url, url_e)) | |
| 2287 logging.warn(err_msg) | |
|
Paweł Hajdan Jr.
2014/08/08 11:13:50
Why do we need this (here and below) if we actuall
sheyang
2014/08/11 19:30:05
Removed.
| |
| 2288 except ValueError as val_e: | |
| 2289 err_msg = 'Invalid json string from %s. Error: %s.' % (map_url, val_e) | |
| 2290 logging.warn(err_msg) | |
| 2291 | |
| 2292 if master_map: | |
|
Paweł Hajdan Jr.
2014/08/08 11:13:50
Have you tested the code path when we catch an exc
sheyang
2014/08/11 19:30:05
Done.
| |
| 2293 for bot in options.bot: | |
| 2294 if ':' in bot: | |
| 2295 builder, _ = bot.split(':', 1) | |
| 2296 else: | |
| 2297 builder = bot | |
| 2298 master_list = master_map.get(builder, []) | |
| 2299 if not master_list: | |
| 2300 err_msg = 'Cannot find a master for builder %s.' % builder | |
| 2301 break | |
| 2302 elif len(master_list) > 1: | |
| 2303 err_msg = ('The builder name %s exists in multiple masters %s.' % | |
| 2304 (builder, master_list)) | |
| 2305 break | |
| 2306 else: | |
| 2307 cur_master = master_list[0] | |
| 2308 if not options.master: | |
| 2309 options.master = cur_master | |
| 2310 elif options.master != cur_master: | |
| 2311 err_msg = 'The builders do not belong to the same master.' | |
| 2312 break | |
| 2313 | |
| 2314 if err_msg: | |
| 2315 parser.error('Tryserver master cannot be found because: %s\n' | |
| 2316 'Please manually specify the tryserver master' | |
| 2317 ', e.g. "-m tryserver.chromium.linux".' % err_msg) | |
| 2281 | 2318 |
| 2282 def GetMasterMap(): | 2319 def GetMasterMap(): |
| 2283 # Process --bot and --testfilter. | 2320 # Process --bot and --testfilter. |
| 2284 if not options.bot: | 2321 if not options.bot: |
| 2285 change = cl.GetChange(cl.GetCommonAncestorWithUpstream(), None) | 2322 change = cl.GetChange(cl.GetCommonAncestorWithUpstream(), None) |
| 2286 | 2323 |
| 2287 # Get try masters from PRESUBMIT.py files. | 2324 # Get try masters from PRESUBMIT.py files. |
| 2288 masters = presubmit_support.DoGetTryMasters( | 2325 masters = presubmit_support.DoGetTryMasters( |
| 2289 change, | 2326 change, |
| 2290 change.LocalPaths(), | 2327 change.LocalPaths(), |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2633 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2670 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
| 2634 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2671 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 2635 | 2672 |
| 2636 | 2673 |
| 2637 if __name__ == '__main__': | 2674 if __name__ == '__main__': |
| 2638 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2675 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 2639 # unit testing. | 2676 # unit testing. |
| 2640 fix_encoding.fix_encoding() | 2677 fix_encoding.fix_encoding() |
| 2641 colorama.init() | 2678 colorama.init() |
| 2642 sys.exit(main(sys.argv[1:])) | 2679 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |