Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make progress_bar an extra feature #361

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion podman/domain/images_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import urllib.parse
from typing import Any, Dict, Generator, Iterator, List, Mapping, Optional, Union
import requests
from rich.progress import Progress, TextColumn, BarColumn, TaskProgressColumn, TimeRemainingColumn

from podman import api
from podman.api import Literal
Expand All @@ -17,6 +16,17 @@
from podman.domain.registry_data import RegistryData
from podman.errors import APIError, ImageNotFound

try:
from rich.progress import (
Progress,
TextColumn,
BarColumn,
TaskProgressColumn,
TimeRemainingColumn,
)
except (ImportError, ModuleNotFoundError):
Progress = None

logger = logging.getLogger("podman.images")


Expand Down Expand Up @@ -314,6 +324,8 @@ def pull(
# progress bar
progress_bar = kwargs.get("progress_bar", False)
if progress_bar:
if Progress is None:
raise ModuleNotFoundError('progress_bar requires \'rich.progress\' module')
params["compatMode"] = True
stream = True

Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ sphinx
tomli>=1.2.3; python_version<'3.11'
urllib3
wheel
rich >= 12.5.1
6 changes: 6 additions & 0 deletions rpm/python-podman.spec
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,19 @@ export PBR_VERSION="0.0.0"
%pyproject_save_files %{pypi_name}
%endif

%if !%{defined rhel8_py}
%check
%pyproject_check_import -e podman.api.typing_extensions
%endif

%if %{defined rhel8_py}
%files -n python%{python3_pkgversion}-%{pypi_name}
%dir %{python3_sitelib}/%{pypi_name}-*-py%{python3_version}.egg-info
%{python3_sitelib}/%{pypi_name}-*-py%{python3_version}.egg-info/*
%dir %{python3_sitelib}/%{pypi_name}
%{python3_sitelib}/%{pypi_name}/*
%else
%pyproject_extras_subpkg -n python%{python3_pkgversion}-%{pypi_name} progress_bar
%files -n python%{python3_pkgversion}-%{pypi_name} -f %{pyproject_files}
%endif
%license LICENSE
Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ install_requires =
requests >=2.24
tomli>=1.2.3; python_version<'3.11'
urllib3

[options.extras_require]
progress_bar =
rich >= 12.5.1

# typing_extensions are included for RHEL 8.5
Expand Down
1 change: 0 additions & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ pylint
pytest
requests-mock >= 1.11.0
tox
rich >= 12.5.1
Loading