Exemple #1
0
def create_docker_image(args):
    """Create a directory containing all the necessary ingredients to construct a docker image.

    Returns the created DockerDevice objects.
    """

    cfg = DockerConfig()
    if args.metrics:
        cfg.set_collect_metrics(True)
    if args.no_metrics:
        cfg.set_collect_metrics(False)

    if not cfg.decided_on_metrics():
        logging.warning(
            "Please opt in or out of metrics collection.\n"
            "You will receive this warning until an option is selected.\n"
            "To opt in or out pass the --metrics or --no-metrics flag\n"
            "Note, that metrics will only be collected if you opt in.")

    imgzip = [args.imgzip]
    if not os.path.exists(imgzip[0]):
        imgzip = [
            x.download() for x in emu_downloads_menu.find_image(imgzip[0])
        ]

    emuzip = [args.emuzip]
    if emuzip[0] in ["stable", "canary", "all"]:
        emuzip = [
            x.download() for x in emu_downloads_menu.find_emulator(emuzip[0])
        ]
    elif re.match("\d+", emuzip[0]):
        # We must be looking for a build id
        logging.info("Treating %s as a build id", emuzip[0])
        emuzip = [emu_downloads_menu.download_build(emuzip[0])]

    devices = []
    for (img, emu) in itertools.product(imgzip, emuzip):
        logging.info("Processing %s, %s", img, emu)
        rel = emu_downloads_menu.AndroidReleaseZip(img)
        if not rel.is_system_image():
            raise Exception(
                "{} is not a zip file with a system image".format(img))
        rel = emu_downloads_menu.AndroidReleaseZip(emu)
        if not rel.is_emulator():
            raise Exception(
                "{} is not a zip file with an emulator".format(emu))

        device = DockerDevice(emu, img, args.dest, args.gpu, args.repo,
                              args.tag)
        device.create_docker_file(args.extra, cfg.collect_metrics())
        img = device.create_container()
        if img and args.start:
            device.launch(img)
        if args.push:
            device.push(img)
        devices.append(device)

    return devices
Exemple #2
0
def create_docker_image_interactive(args):
    """Interactively create a docker image by selecting the desired combination from a menu."""
    img = emu_downloads_menu.select_image(args.arm) or sys.exit(1)
    emulator = emu_downloads_menu.select_emulator() or sys.exit(1)

    img_zip = img.download()
    emu_zip = emulator.download("linux")
    device = DockerDevice(emu_zip, img_zip, args.dest)
    device.create_docker_file(args.extra)
    img = device.create_container()
    if img and args.start:
        device.launch(img)
Exemple #3
0
def create_docker_image(args):
    """Create a directory containing all the necessary ingredients to construct a docker image."""
    imgzip = args.imgzip
    if not os.path.exists(imgzip):
        imgzip = emu_downloads_menu.find_image(imgzip).download()

    emuzip = args.emuzip
    if emuzip in ['stable', 'canary']:
        emuzip = emu_downloads_menu.find_emulator(emuzip).download()

    device = DockerDevice(emuzip, imgzip, args.dest, args.tag)
    device.create_docker_file(args.extra)
    img = device.create_container()
    if img and args.start:
        device.launch(img)
def create_docker_image_interactive(args):
    """Interactively create a docker image by selecting the desired combination from a menu."""
    img = emu_downloads_menu.select_image(args.arm) or sys.exit(1)
    emulator = emu_downloads_menu.select_emulator() or sys.exit(1)
    cfg = DockerConfig()
    metrics = False

    if not cfg.decided_on_metrics():
        cfg.set_collect_metrics(
            click.confirm(
                "Would you like to help make the emulator better by sending usage statistics to Google upon (graceful) emulator exit?"
            ))
    metrics = cfg.collect_metrics()

    img_zip = img.download()
    emu_zip = emulator.download("linux")
    device = DockerDevice(emu_zip, img_zip, args.dest, args.gpu)
    device.create_docker_file(args.extra, metrics)
    img = device.create_container()
    if img and args.start:
        device.launch(img)