예제 #1
0
async def bouncer(product, version):
    """Make sure bouncer redirects to the expected version (or a later one)."""
    channel = get_version_channel(product, version)
    channel_value = channel.value

    if product == 'thunderbird' and channel == Channel.NIGHTLY:
        # NIGHTLY is a valid channel for Thunderbird, but it does not use the bouncer
        return build_task_response(True, "", "No nightly bouncer for Thunderbird.")

    if product == 'devedition':
        channel_value = "DEVEDITION"
        product_channel = 'firefox-{}'.format(channel_value.lower())
    else:  # product is 'firefox' or 'thunderbird'
        if channel == Channel.RELEASE:
            product_channel = product
        else:
            product_channel = '{}-{}'.format(product, channel_value.lower())

    url = 'https://download.mozilla.org?product={}-latest-ssl&os=linux64&lang=en-US'.format(
            product_channel)

    async with get_session() as session:
        async with session.get(url, allow_redirects=False) as resp:
            if resp.status == 302:
                url = resp.headers['Location']
            else:
                msg = 'Bouncer is down ({}).'.format(resp.status)
                raise TaskError(msg, url=url)

            filename = os.path.basename(url)
            last_release = get_version_from_filename(filename)
            status = build_version_id(last_release) >= build_version_id(version)
            message = "Bouncer for {} redirects to version {}".format(channel_value, last_release)
            return build_task_response(status, url, message)
예제 #2
0
async def download_links(product, version):
    channel = get_version_channel(product, version)
    url = get_downloads_url(product, channel)

    async with get_session() as session:
        async with session.get(url) as resp:
            if resp.status != 200:
                msg = 'Download page not available  ({})'.format(resp.status)
                raise TaskError(msg)
            body = await resp.text()
            d = pq(body)

            if product == 'thunderbird':
                if channel is Channel.NIGHTLY:
                    link_path = ".download-link.btn-nightly"
                    url = d(link_path).attr('href')
                    filename = os.path.basename(url)
                    last_release = get_version_from_filename(filename)
                else:
                    last_release = d("#all-downloads").attr(
                        'data-thunderbird-version')
            else:
                if channel in (Channel.NIGHTLY, Channel.BETA, Channel.AURORA):
                    if product == 'devedition':
                        link_path = "#intro-download > .download-list > .os_linux64 > a"
                    elif channel is Channel.NIGHTLY:
                        link_path = "#desktop-nightly-download > .download-list > .os_linux64 > a"
                    else:  # channel is Channel.BETA:
                        link_path = "#desktop-beta-download > .download-list > .os_linux64 > a"
                    url = d(link_path).attr('href')
                    async with session.get(url, allow_redirects=False) as resp:
                        url = resp.headers['Location']
                        filename = os.path.basename(url)
                        last_release = get_version_from_filename(filename)
                elif channel is Channel.ESR:
                    version = re.sub('esr$', '', version)
                    last_release = d("html").attr('data-esr-versions')
                else:
                    # Does the content contains the version number?
                    last_release = d("html").attr('data-latest-firefox')

            status = build_version_id(last_release) >= build_version_id(
                version)
            message = (
                "The download links for release have been published for version {}"
                .format(last_release))
            return build_task_response(status, url, message)
예제 #3
0
async def bouncer(product, version):
    """Fetch bedrock download page to grab the bouncer download link and then make sure
    it redirects to the expected version."""
    channel = get_version_channel(product, version)
    channel_value = channel.value

    if channel is Channel.ESR:
        bedrock_url = "https://www.mozilla.org/en-US/{}/organizations/all/".format(
            product)
    elif channel is Channel.RELEASE:
        bedrock_url = 'https://www.mozilla.org/en-US/{}/all/'.format(product)
    else:
        bedrock_url = 'https://www.mozilla.org/fr/{}/channel/desktop/'.format(
            product)
        if product == 'devedition':
            bedrock_url = 'https://www.mozilla.org/en-US/firefox/developer/'
            channel_value = "DEVEDITION"

    async with get_session() as session:
        async with session.get(bedrock_url) as resp:
            if resp.status != 200:
                msg = 'Download page not available  ({})'.format(resp.status)
                raise TaskError(msg, url=bedrock_url)
            body = await resp.text()
            d = pq(body)

            if product == 'devedition':
                link_path = "#intro-download > .download-list > .os_linux64 > a"
            elif channel is Channel.NIGHTLY:
                link_path = "#desktop-nightly-download > .download-list > .os_linux64 > a"
            elif channel in (Channel.BETA, Channel.AURORA):
                link_path = "#desktop-beta-download > .download-list > .os_linux64 > a"
            else:  # channel in (Channel.RELEASE, Channel.ESR):
                link_path = "#fr > .linux64 > a"

            url = d(link_path).attr('href')

            if url is not None:
                async with session.get(url, allow_redirects=False) as resp:
                    if resp.status == 302:
                        url = resp.headers['Location']
                    else:
                        msg = 'Bouncer is down ({}).'.format(resp.status)
                        raise TaskError(msg, url=url)
            else:
                msg = 'No links found.'.format(resp.status)
                raise TaskError(msg, url=bedrock_url)

            filename = os.path.basename(url)
            last_release = get_version_from_filename(filename)
            status = build_version_id(last_release) >= build_version_id(
                version)
            message = "Bouncer for {} redirects to version {}".format(
                channel_value, last_release)
            return build_task_response(status, url, message)
예제 #4
0
def test_get_version_from_filename(filename, version):
    assert get_version_from_filename(filename) == version