Esempio n. 1
0
async def fetch_release_candidate_metadata(session, record):
    """A JSON file containing build info is published along the
    nightly build archive.
    """
    global _rc_metadata

    url = record['download']['url']

    # Make sure the rc URL is turned into a en-US one.
    rc_url = localize_release_candidate_url(url)

    if rc_url in _rc_metadata:
        return _rc_metadata[rc_url]

    product = record['source']['product']
    if product == 'devedition':
        product = 'firefox'
    if product == 'fennec':
        metadata_url = re.sub('\.({})$'.format('|'.join(FILE_EXTENSIONS)),
                              '.json', rc_url)
    else:
        major_version = record['target']['version'].split('rc')[0]
        parts = rc_url.split('/')
        parts[-1] = '{}-{}.json'.format(product, major_version)
        metadata_url = '/'.join(parts)
    try:
        metadata = await fetch_json(session, metadata_url)
    except aiohttp.ClientError as e:
        # Old RC like https://archive.mozilla.org/pub/firefox/releases/1.0rc1/
        # don't have metadata.
        logger.warning(f"Could not fetch metadata for '{record['id']}' "
                       f"from '{metadata_url}'")
        _rc_metadata[rc_url] = None  # Don't try it anymore.
        return None

    m = re.search('/build(\d+)/', url)
    metadata['buildnumber'] = int(m.group(1))

    _rc_metadata[rc_url] = metadata
    return metadata
Esempio n. 2
0
def test_localize_rc_url(localized_url, american_url):
    assert localize_release_candidate_url(localized_url) == american_url