put app progress in panel, speed things up

This commit is contained in:
Kenneth Hoste 2021-10-16 13:48:36 +02:00
parent b9af6f7d8f
commit 8a1585f2cf
No known key found for this signature in database
GPG Key ID: 90C14B582D70E3BE
1 changed files with 6 additions and 5 deletions

View File

@ -9,6 +9,7 @@ each of which consisting of multiple steps.
import time import time
from rich.console import Group from rich.console import Group
from rich.panel import Panel
from rich.live import Live from rich.live import Live
from rich.progress import ( from rich.progress import (
BarColumn, BarColumn,
@ -29,7 +30,7 @@ def run_steps(name, step_times, app_steps_task_id):
# run steps, update progress # run steps, update progress
for _ in range(step_time): for _ in range(step_time):
time.sleep(1) time.sleep(0.5)
step_progress.update(step_task_id, advance=1) step_progress.update(step_task_id, advance=1)
# stop and hide progress bar for this step when done # stop and hide progress bar for this step when done
@ -69,15 +70,15 @@ overall_progress = Progress(
# group of progress bars; # group of progress bars;
# some are always visible, others will disappear when progress is complete # some are always visible, others will disappear when progress is complete
progress_group = Group( progress_group = Group(
current_app_progress, step_progress, app_steps_progress, overall_progress Panel(Group(current_app_progress, step_progress, app_steps_progress)), overall_progress
) )
# tuple specifies how long each step takes for that app # tuple specifies how long each step takes for that app
step_actions = ("downloading", "configuring", "building", "installing") step_actions = ("downloading", "configuring", "building", "installing")
apps = [ apps = [
("one", (3, 2, 5, 3)), ("one", (2, 1, 4, 2)),
("two", (2, 5, 10, 6)), ("two", (1, 3, 8, 4)),
("three", (5, 1, 5, 3)), ("three", (2, 1, 3, 2)),
] ]
# create overall progress bar # create overall progress bar