Skip to content

Commit

Permalink
Update pull progress bar colour
Browse files Browse the repository at this point in the history
The Downloading bar is now in the default terminal
text color and is bolded for better visibility.
Bars will switch to green when completed.

Signed-off-by: Urvashi Mohnani <[email protected]>
  • Loading branch information
umohnani8 committed Nov 14, 2023
1 parent a9049e8 commit 4240f56
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions podman/domain/images_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import urllib.parse
from typing import Any, Dict, Generator, Iterator, List, Mapping, Optional, Union
import requests
from rich.progress import Progress
from rich.progress import Progress, TextColumn, BarColumn, TaskProgressColumn, TimeRemainingColumn

from podman import api
from podman.api import Literal
Expand Down Expand Up @@ -323,7 +323,13 @@ def pull(
if progress_bar:
tasks = {}
print("Pulling", params["reference"])
with Progress() as progress:
progress = Progress(
TextColumn("[progress.description]{task.description}"),
BarColumn(complete_style="default", finished_style="green"),
TaskProgressColumn(),
TimeRemainingColumn(),
)
with progress:
for line in response.iter_lines():
decoded_line = json.loads(line.decode('utf-8'))
self.__show_progress_bar(decoded_line, progress, tasks)
Expand All @@ -350,7 +356,7 @@ def __show_progress_bar(self, line, progress, tasks):
description = f'[green][Download complete {line["id"]}]'
completed = True
elif line['status'] == 'Downloading':
description = f'[red][Downloading {line["id"]}]'
description = f'[bold][Downloading {line["id"]}]'
else:
# skip other statuses
return
Expand Down

0 comments on commit 4240f56

Please sign in to comment.