def GetBuilderMaster(bot_list):
    'For a given builder, fetch the master from AE if available.'
    map_url = 'https://builders-map.appspot.com/'
    try:
        master_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)))
    if (not master_map):
        return (None, 'Failed to build master map.')
    result_master = ''
    for bot in bot_list:
        builder = bot.split(':', 1)[0]
        master_list = master_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.' % (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)
For a given builder, fetch the master from AE if available.
def GetBuilderMaster(bot_list):
    
    map_url = 'https://builders-map.appspot.com/'
    try:
        master_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)))
    if (not master_map):
        return (None, 'Failed to build master map.')
    result_master = 
    for bot in bot_list:
        builder = bot.split(':', 1)[0]
        master_list = master_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.' % (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)