Index: git_cl.py |
diff --git a/git_cl.py b/git_cl.py |
index c78207bdc9ee4f1ab1541ec1ca74238d8621b377..f082d34db6168b1bec28efed9c01062ae6e3af05 100755 |
--- a/git_cl.py |
+++ b/git_cl.py |
@@ -4683,35 +4683,34 @@ def GetTreeStatusReason(): |
return status['message'] |
-def GetBuilderMaster(bot_list): |
- """For a given builder, fetch the master from AE if available.""" |
+def GetBuilderMasters(bot_list): |
+ """Returns a map of masters to builders for the given builders.""" |
map_url = 'https://builders-map.appspot.com/' |
try: |
- master_map = json.load(urllib2.urlopen(map_url)) |
+ builders_map = json.load(urllib2.urlopen(map_url)) |
except urllib2.URLError as e: |
return None, ('Failed to fetch builder-to-master map from %s. Error: %s.' % |
(map_url, e)) |
except ValueError as e: |
return None, ('Invalid json string from %s. Error: %s.' % (map_url, e)) |
tandrii(chromium)
2016/10/23 17:00:02
this Go-style error reporting makes me sad in Pyth
qyearsley
2016/10/24 21:33:39
Yeah -- I guess another way to do it is to raise a
|
- if not master_map: |
+ if not builders_map: |
return None, 'Failed to build master map.' |
- result_master = '' |
+ master_map = {} |
for bot in bot_list: |
builder = bot.split(':', 1)[0] |
- master_list = master_map.get(builder, []) |
+ master_list = builders_map.get(builder, []) |
if not master_list: |
return None, ('No matching master for builder %s.' % builder) |
elif len(master_list) > 1: |
- return None, ('The builder name %s exists in multiple masters %s.' % |
+ return None, ('The builder name %s exists in multiple masters %s.' % |
(builder, master_list)) |
else: |
- cur_master = master_list[0] |
- if not result_master: |
- result_master = cur_master |
- elif result_master != cur_master: |
- return None, 'The builders do not belong to the same master.' |
- return result_master, None |
+ master = master_list[0] |
+ master_map.setdefault(master, []) |
+ master_map[master].append(bot) |
+ |
+ return master_map, None |
def CMDtree(parser, args): |
@@ -4807,13 +4806,6 @@ def CMDtry(parser, args): |
if options.bucket and options.master: |
parser.error('Only one of --bucket and --master may be used.') |
- if options.bot and not options.master and not options.bucket: |
- options.master, err_msg = GetBuilderMaster(options.bot) |
- if err_msg: |
- parser.error('Tryserver master cannot be found because: %s\n' |
- 'Please manually specify the tryserver master' |
- ', e.g. "-m tryserver.chromium.linux".' % err_msg) |
- |
def GetMasterMap(): |
# Process --bot. |
if not options.bot: |
@@ -4870,7 +4862,16 @@ def CMDtry(parser, args): |
bucket = _prefix_master(options.master) |
return {bucket: builders_and_tests} |
- if options.bucket: |
+ if options.bot and not options.master and not options.bucket: |
+ masters, err_msg = GetBuilderMasters(options.bot) |
+ if err_msg: |
+ parser.error('Try server masters cannot be found because: %s\n' |
+ 'Please manually specify the try server masters' |
+ ', e.g. "-m tryserver.chromium.linux".' % err_msg) |
+ buckets = {} |
+ for master, builders in masters.iteritems(): |
+ buckets[_prefix_master(master)] = {b: [] for b in builders} |
+ elif options.bucket: |
buckets = {options.bucket: {b: [] for b in options.bot}} |
else: |
buckets = GetMasterMap() |