MCPcopy
hub / github.com/usestrix/strix / pull_docker_image

Function pull_docker_image

strix/interface/main.py:636–683  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

634
635
636def pull_docker_image() -> None:
637 console = Console()
638 client = check_docker_connection()
639
640 image = load_settings().runtime.image
641
642 if image_exists(client, image):
643 logger.debug("Docker image already present locally: %s", image)
644 return
645
646 logger.info("Pulling docker image: %s", image)
647 console.print()
648 console.print(f"[dim]Pulling image[/] {image}")
649 console.print("[dim yellow]This only happens on first run and may take a few minutes...[/]")
650 console.print()
651
652 with console.status("[bold cyan]Downloading image layers...", spinner="dots") as status:
653 try:
654 layers_info: dict[str, str] = {}
655 last_update = ""
656
657 for line in client.api.pull(image, stream=True, decode=True):
658 last_update = process_pull_line(line, layers_info, status, last_update)
659
660 except DockerException as e:
661 logger.exception("Failed to pull docker image %s", image)
662 console.print()
663 error_text = Text()
664 error_text.append("FAILED TO PULL IMAGE", style="bold red")
665 error_text.append("\n\n", style="white")
666 error_text.append(f"Could not download: {image}\n", style="white")
667 error_text.append(str(e), style="dim red")
668
669 panel = Panel(
670 error_text,
671 title="[bold white]STRIX",
672 title_align="left",
673 border_style="red",
674 padding=(1, 2),
675 )
676 console.print(panel, "\n")
677 sys.exit(1)
678
679 logger.info("Docker image %s ready", image)
680 success_text = Text()
681 success_text.append("Docker image ready", style="#22c55e")
682 console.print(success_text)
683 console.print()
684
685
686def main() -> None:

Callers 1

mainFunction · 0.85

Calls 4

check_docker_connectionFunction · 0.90
load_settingsFunction · 0.90
image_existsFunction · 0.90
process_pull_lineFunction · 0.90

Tested by

no test coverage detected