diff --git a/Dockerfile b/Dockerfile index e14e7bb..44808bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ from naddeoa/booty:ubuntu22.04 -RUN --mount=type=cache,target=/var/cache/apt sudo apt install -y python3 python3-pip # MANUAL install pip +RUN sudo apt-get update +RUN --mount=type=cache,target=/var/cache/apt sudo apt-get install -y python3 python3-pip # MANUAL install pip COPY ./dist/*.whl ./ RUN --mount=type=cache,target=/home/myuser/.cache pip install --user ./*.whl # MANUAL install booty diff --git a/Dockerfile.base b/Dockerfile.base index f0ca2a1..b33c786 100644 --- a/Dockerfile.base +++ b/Dockerfile.base @@ -6,8 +6,8 @@ from ubuntu:22.04 ENV DEBIAN_FRONTEND=noninteractive RUN --mount=type=cache,target=/var/cache/apt < StatusResult: status_result = StatusResult() total_time = 0.0 - group = Group(table, overall_progress) - with Live(group, refresh_per_second=_REFRESH_RATE): + padder = Padder() + padding = Padding(table, (0, 0, 0, 0)) + group = Group(padding, overall_progress) + + with Live(auto_refresh=False) as live: for target in self.data.G.iterator(): deps_string = dependency_strings[target] @@ -127,7 +130,7 @@ def status(self) -> StatusResult: dependency_text = Text(deps_string) status_text = Text("🟡 Checking...") - tree = StdTree(self._display_setup(self.data.execution_index[target])) + tree = StdTree(self._display_is_setup(self.data.execution_index[target])) time_text = Text("") # Make update in real time @@ -137,6 +140,10 @@ def status(self) -> StatusResult: cmd = CommandExecutor(self.data, target, "is_setup") for _ in cmd.execute(): time_text.plain = f"{time.perf_counter() - start_time:.2f}s" + tree.set_stdout(cmd.latest_stdout()) + tree.set_stderr(cmd.latest_stderr()) + padding.bottom = padder.get_padding(tree) + live.update(group, refresh=True) target_time = time.perf_counter() - start_time total_time += target_time @@ -160,6 +167,7 @@ def status(self) -> StatusResult: self.logger.log_is_setup(target, cmd.all_stdout(), cmd.all_stderr()) overall_progress.advance(overall_id) + live.update(group, refresh=True) overall_progress.update(overall_id, completed=True) overall_progress.update(overall_id, visible=False) @@ -181,16 +189,14 @@ def install_missing(self, status_result: StatusResult) -> StatusResult: overall_progress = Progress() overall_id = overall_progress.add_task("Status", total=len(missing_packages)) - # table_padding = Text("\n" * (len(missing_packages) + 1)) - - max_padding = 0 + padder = Padder() padding = Padding(table, (0, 0, 0, 0)) group = Group(padding, overall_progress) total_time = 0.0 status_result = StatusResult() gen = self.data.G.bfs() - with Live() as live: + with Live(auto_refresh=False) as live: try: next(gen) # Skip the first fake target target = gen.send(True) @@ -214,9 +220,8 @@ def install_missing(self, status_result: StatusResult) -> StatusResult: time_text.plain = f"{time.perf_counter() - start_time:.2f}s" tree.set_stdout(cmd.latest_stdout()) tree.set_stderr(cmd.latest_stderr()) - max_padding = max(max_padding, tree.height()) - padding.bottom = abs(max_padding - tree.height()) - live.update(group) + padding.bottom = padder.get_padding(tree) + live.update(group, refresh=True) cmd_time = time.perf_counter() - start_time time_text.plain = f"{cmd_time:.2f}s" @@ -226,9 +231,7 @@ def install_missing(self, status_result: StatusResult) -> StatusResult: status_result.installed.append(target) status_text.plain = "🟢 Installed" tree.reset() - padding.bottom = abs(max_padding - tree.height()) - live.update(group) - + padding.bottom = padder.get_padding(tree) else: status_text.plain = "🔴 Error" self.logger.log_setup(target, cmd.all_stdout(), cmd.all_stderr()) @@ -236,7 +239,7 @@ def install_missing(self, status_result: StatusResult) -> StatusResult: target = gen.send(cmd.code == 0) overall_progress.advance(overall_id) - live.update(group) + live.update(group, refresh=True) except StopIteration as e: skipped: List[str] = e.value diff --git a/booty/lang/stdlib.booty b/booty/lang/stdlib.booty index d48d1d5..5c26365 100644 --- a/booty/lang/stdlib.booty +++ b/booty/lang/stdlib.booty @@ -10,7 +10,6 @@ recipe apt(packages): recipe ppa(name): setup: - apt(software-properties-common) sudo add-apt-repository -y $((name)) sudo apt-get update is_setup: grep $((name)) /etc/apt/sources.list diff --git a/booty/ui.py b/booty/ui.py index ef3d808..9d9accb 100644 --- a/booty/ui.py +++ b/booty/ui.py @@ -1,9 +1,4 @@ from typing import List, Optional -from rich.console import Group -from rich.live import Live -from rich.progress import Progress -from rich.padding import Padding -from rich.table import Table from rich.text import Text from rich.tree import Tree @@ -68,20 +63,11 @@ def height(self) -> int: return cmd_height + stdout_height + stderr_height -class PaddedTable: - def __init__(self, table: Table, total: int) -> None: - self.table = table - self._progress = Progress() - # self.progress_id = progress.add_task("Status", total=total) +class Padder: + def __init__(self) -> None: self._max_padding = 0 - self._padding = Padding(table, (0, 0, 0, 0)) - self._group = Group(self._padding, self._progress) - # def get_std_tree(self, cmd: str) -> StdTree: - # self.std_tree = StdTree(self._display_setup(self.data.execution_index[target])) - - def update(self, live: Live) -> None: - pass - - # self._padding.bottom = abs(self._max_padding - self.std_tree.height()) - # live.update(group) + def get_padding(self, tree: StdTree) -> int: + height = tree.height() + self._max_padding = max(self._max_padding, height) + return self._max_padding - height diff --git a/examples/install.booty b/examples/install.booty index 5d2f208..983ef6d 100644 --- a/examples/install.booty +++ b/examples/install.booty @@ -4,7 +4,7 @@ essentials: apt(wget git vim autokey-gtk silversearcher-ag gawk xclip gnome-disk-utility cryptsetup build-essential dconf-editor ripgrep xdotool - luarocks cmake libterm-readkey-perl expect ssh curl fzf) + luarocks cmake libterm-readkey-perl expect ssh curl fzf software-properties-common) files.git -> essentials files.git: git(naddeo@do.naddeo.org:~/git/files, ~/files) @@ -141,6 +141,7 @@ node: ## Racket ## +racket -> essentials racket: setup: ppa(ppa:plt/racket) diff --git a/pyproject.toml b/pyproject.toml index f192787..29330eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,20 +8,21 @@ keywords = ["bootstrap", "booty", "setup", "cli", "tool"] authors = ["Anthony Naddeo "] license = "MIT" readme = "README.md" -packages = [{ include = "booty/**/*.py" }] - +packages = [ + { include = "booty/**/*.py"}, + { include = "booty/**/*.lark"}, + { include = "booty/**/*.booty"} +] [tool.poetry.scripts] booty = "booty.cli:cli" - [tool.poetry.dependencies] python = ">=3.9, <3.13" lark = "^1.1.8" click = "^8.1.7" rich = "^13.7.0" - [tool.poetry.group.dev.dependencies] pyright = "^1.1.338" ruff = "^0.1.7"