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 2190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2201 """Fetches the tree status from a json url and returns the message | 2201 """Fetches the tree status from a json url and returns the message |
| 2202 with the reason for the tree to be opened or closed.""" | 2202 with the reason for the tree to be opened or closed.""" |
| 2203 url = settings.GetTreeStatusUrl() | 2203 url = settings.GetTreeStatusUrl() |
| 2204 json_url = urlparse.urljoin(url, '/current?format=json') | 2204 json_url = urlparse.urljoin(url, '/current?format=json') |
| 2205 connection = urllib2.urlopen(json_url) | 2205 connection = urllib2.urlopen(json_url) |
| 2206 status = json.loads(connection.read()) | 2206 status = json.loads(connection.read()) |
| 2207 connection.close() | 2207 connection.close() |
| 2208 return status['message'] | 2208 return status['message'] |
| 2209 | 2209 |
| 2210 | 2210 |
| 2211 def GetBuilderMaster(bot_list): | |
| 2212 """For a given builder, fetch the master from AE if available.""" | |
| 2213 err_msg = '' | |
|
M-A Ruel
2014/08/14 19:59:38
remove
sheyang
2014/08/14 20:45:09
Done.
| |
| 2214 master_map = None | |
|
M-A Ruel
2014/08/14 19:59:38
Remove
sheyang
2014/08/14 20:45:09
Done.
| |
| 2215 result_master = '' | |
|
M-A Ruel
2014/08/14 19:59:38
Move to line 2229
sheyang
2014/08/14 20:45:08
Done.
| |
| 2216 map_url = 'https://builders-map.appspot.com/' | |
| 2217 try: | |
| 2218 master_map = json.load(urllib2.urlopen(map_url)) | |
| 2219 except urllib2.URLError as e: | |
| 2220 err_msg = ('Failed to fetch builder-to-master map from %s. Error: %s.' % | |
|
M-A Ruel
2014/08/14 19:59:38
return None, ('...
sheyang
2014/08/14 20:45:09
Do you want to get rid of the err_msg variable?
M-A Ruel
2014/08/14 20:47:37
Exact, it serves no purpose.
| |
| 2221 (map_url, e)) | |
| 2222 return None, err_msg | |
| 2223 except ValueError as e: | |
| 2224 err_msg = 'Invalid json string from %s. Error: %s.' % (map_url, e) | |
|
M-A Ruel
2014/08/14 19:59:38
return None, '...
and for the lines below.
| |
| 2225 return None, err_msg | |
| 2226 | |
| 2227 if not master_map: | |
| 2228 return None, err_msg | |
| 2229 | |
| 2230 for bot in bot_list: | |
| 2231 builder = bot.split(':', 1)[0] | |
| 2232 master_list = master_map.get(builder, []) | |
| 2233 if not master_list: | |
| 2234 err_msg = 'No matching master for builder %s.' % builder | |
| 2235 return None, err_msg | |
| 2236 elif len(master_list) > 1: | |
| 2237 err_msg = ('The builder name %s exists in multiple masters %s.' % | |
| 2238 (builder, master_list)) | |
| 2239 return None, err_msg | |
| 2240 else: | |
| 2241 cur_master = master_list[0] | |
| 2242 if not result_master: | |
| 2243 result_master = cur_master | |
| 2244 elif result_master != cur_master: | |
| 2245 err_msg = 'The builders do not belong to the same master.' | |
| 2246 return None, err_msg | |
| 2247 return result_master, err_msg | |
|
M-A Ruel
2014/08/14 19:59:38
return result_master, None
sheyang
2014/08/14 20:45:09
Done.
| |
| 2248 | |
| 2249 | |
| 2211 def CMDtree(parser, args): | 2250 def CMDtree(parser, args): |
| 2212 """Shows the status of the tree.""" | 2251 """Shows the status of the tree.""" |
| 2213 _, args = parser.parse_args(args) | 2252 _, args = parser.parse_args(args) |
| 2214 status = GetTreeStatus() | 2253 status = GetTreeStatus() |
| 2215 if 'unset' == status: | 2254 if 'unset' == status: |
| 2216 print 'You must configure your tree status URL by running "git cl config".' | 2255 print 'You must configure your tree status URL by running "git cl config".' |
| 2217 return 2 | 2256 return 2 |
| 2218 | 2257 |
| 2219 print "The tree is %s" % status | 2258 print "The tree is %s" % status |
| 2220 print | 2259 print |
| 2221 print GetTreeStatusReason() | 2260 print GetTreeStatusReason() |
| 2222 if status != 'open': | 2261 if status != 'open': |
| 2223 return 1 | 2262 return 1 |
| 2224 return 0 | 2263 return 0 |
| 2225 | 2264 |
| 2226 | 2265 |
| 2227 def CMDtry(parser, args): | 2266 def CMDtry(parser, args): |
| 2228 """Triggers a try job through Rietveld.""" | 2267 """Triggers a try job through Rietveld.""" |
| 2229 group = optparse.OptionGroup(parser, "Try job options") | 2268 group = optparse.OptionGroup(parser, "Try job options") |
| 2230 group.add_option( | 2269 group.add_option( |
| 2231 "-b", "--bot", action="append", | 2270 "-b", "--bot", action="append", |
| 2232 help=("IMPORTANT: specify ONE builder per --bot flag. Use it multiple " | 2271 help=("IMPORTANT: specify ONE builder per --bot flag. Use it multiple " |
| 2233 "times to specify multiple builders. ex: " | 2272 "times to specify multiple builders. ex: " |
| 2234 "'-bwin_rel:ui_tests,webkit_unit_tests -bwin_layout'. See " | 2273 "'-b win_rel:ui_tests,webkit_unit_tests -b win_layout'. See " |
| 2235 "the try server waterfall for the builders name and the tests " | 2274 "the try server waterfall for the builders name and the tests " |
| 2236 "available. Can also be used to specify gtest_filter, e.g. " | 2275 "available. Can also be used to specify gtest_filter, e.g. " |
| 2237 "-bwin_rel:base_unittests:ValuesTest.*Value")) | 2276 "-b win_rel:base_unittests:ValuesTest.*Value")) |
| 2238 group.add_option( | 2277 group.add_option( |
| 2239 "-m", "--master", default='', | 2278 "-m", "--master", default='', |
| 2240 help=("Specify a try master where to run the tries.")) | 2279 help=("Specify a try master where to run the tries.")) |
| 2241 group.add_option( | 2280 group.add_option( |
| 2242 "-r", "--revision", | 2281 "-r", "--revision", |
| 2243 help="Revision to use for the try job; default: the " | 2282 help="Revision to use for the try job; default: the " |
| 2244 "revision will be determined by the try server; see " | 2283 "revision will be determined by the try server; see " |
| 2245 "its waterfall for more info") | 2284 "its waterfall for more info") |
| 2246 group.add_option( | 2285 group.add_option( |
| 2247 "-c", "--clobber", action="store_true", default=False, | 2286 "-c", "--clobber", action="store_true", default=False, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 2269 parser.error('Need to upload first') | 2308 parser.error('Need to upload first') |
| 2270 | 2309 |
| 2271 props = cl.GetIssueProperties() | 2310 props = cl.GetIssueProperties() |
| 2272 if props.get('private'): | 2311 if props.get('private'): |
| 2273 parser.error('Cannot use trybots with private issue') | 2312 parser.error('Cannot use trybots with private issue') |
| 2274 | 2313 |
| 2275 if not options.name: | 2314 if not options.name: |
| 2276 options.name = cl.GetBranch() | 2315 options.name = cl.GetBranch() |
| 2277 | 2316 |
| 2278 if options.bot and not options.master: | 2317 if options.bot and not options.master: |
| 2279 parser.error('For manually specified bots please also specify the ' | 2318 options.master, err_msg = GetBuilderMaster(options.bot) |
| 2280 'tryserver master, e.g. "-m tryserver.chromium.linux".') | 2319 if err_msg: |
| 2320 parser.error('Tryserver master cannot be found because: %s\n' | |
| 2321 'Please manually specify the tryserver master' | |
| 2322 ', e.g. "-m tryserver.chromium.linux".' % err_msg) | |
| 2281 | 2323 |
| 2282 def GetMasterMap(): | 2324 def GetMasterMap(): |
| 2283 # Process --bot and --testfilter. | 2325 # Process --bot and --testfilter. |
| 2284 if not options.bot: | 2326 if not options.bot: |
| 2285 change = cl.GetChange(cl.GetCommonAncestorWithUpstream(), None) | 2327 change = cl.GetChange(cl.GetCommonAncestorWithUpstream(), None) |
| 2286 | 2328 |
| 2287 # Get try masters from PRESUBMIT.py files. | 2329 # Get try masters from PRESUBMIT.py files. |
| 2288 masters = presubmit_support.DoGetTryMasters( | 2330 masters = presubmit_support.DoGetTryMasters( |
| 2289 change, | 2331 change, |
| 2290 change.LocalPaths(), | 2332 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 ' | 2675 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
| 2634 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2676 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 2635 | 2677 |
| 2636 | 2678 |
| 2637 if __name__ == '__main__': | 2679 if __name__ == '__main__': |
| 2638 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2680 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 2639 # unit testing. | 2681 # unit testing. |
| 2640 fix_encoding.fix_encoding() | 2682 fix_encoding.fix_encoding() |
| 2641 colorama.init() | 2683 colorama.init() |
| 2642 sys.exit(main(sys.argv[1:])) | 2684 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |