Esempio n. 1
0
def trigger_product_details(base_url: str, taskcluster_client_id: str,
                            taskcluster_access_token: str):
    configure_logging()
    data = "{}"
    url = f"{base_url}/product-details"
    click.echo(f"Triggering product details rebuild on {url} url ... ",
               nl=False)
    headers = get_taskcluster_headers(url, "post", data, taskcluster_client_id,
                                      taskcluster_access_token)
    # skip ssl verification when working against development instances
    verify = not any(map(lambda x: x in base_url, ["localhost", "127.0.0.1"]))
    r = requests.post(url, headers=headers, verify=verify, data=data)
    r.raise_for_status()
    click.echo(
        click.style("Product details triggered successfully!", fg="green"))
Esempio n. 2
0
async def rebuild_product_details(
        database_url: str,
        git_repo_url: str,
        folder_in_repo: str,
        channel: str,
        breakpoint_version: typing.Optional[int] = None,
        clean_working_copy: bool = False):
    configure_logging()
    if channel == "development":
        channel = "main"
    engine = sqlalchemy.create_engine(database_url)
    session = sqlalchemy.orm.sessionmaker(bind=engine)()
    click.echo("Product details are building ...")
    await rebuild(session, channel, git_repo_url, folder_in_repo,
                  breakpoint_version, clean_working_copy)
    click.echo("Product details have been rebuilt")
Esempio n. 3
0
async def download_product_details(url: str, download_dir: str):
    """Download product details from `url` to `download_dir`."""
    configure_logging()

    async with aiohttp.ClientSession() as session:
        async with session.get(f"{url}/json_exports.json") as response:
            if response.status != 200:
                response.raise_for_status()
            paths = await response.json()

        await asyncio.gather(*[
            download_json_file(session, f"{url}{path}",
                               f"{download_dir}{path}") for path in paths
            if path.endswith(".json")
            and not os.path.exists(f"{download_dir}{path}")
        ])

    click.echo("All files were downloaded successfully!")
Esempio n. 4
0
def shipit_import(api_from):
    configure_logging()
    session = flask.current_app.db.session

    click.echo("Fetching release list...", nl=False)
    req = requests.get(f"{api_from}/releases?status=shipped,aborted,scheduled")
    req.raise_for_status()
    releases = req.json()

    for release in releases:
        r = Release(
            product=release["product"],
            version=release["version"],
            branch=release["branch"],
            revision=release["revision"],
            build_number=release["build_number"],
            release_eta=release.get("release_eta"),
            partial_updates=release.get("partials"),
            status=release["status"],
        )
        r.created = release["created"]
        r.completed = release["completed"] or release["created"]
        session.add(r)
        session.commit()