diff options
author | Radostin Stoyanov <rstoyanov1@gmail.com> | 2017-07-04 16:24:23 +0100 |
---|---|---|
committer | Cédric Bosdonnat <cbosdonnat@suse.com> | 2017-07-05 13:29:45 +0200 |
commit | b8b69f2f41802bf87e119845a6f532d4970d2481 (patch) | |
tree | eb1cf2d3ccb436379c069ae311e7f575efeeeb3f /src/virtBootstrap/virt_bootstrap.py | |
parent | 9d1bc151c7eb72c1281d6a22476a9082fef8374e (diff) | |
download | virt-bootstrap.git-b8b69f2f41802bf87e119845a6f532d4970d2481.tar.gz virt-bootstrap.git-b8b69f2f41802bf87e119845a6f532d4970d2481.tar.xz virt-bootstrap.git-b8b69f2f41802bf87e119845a6f532d4970d2481.zip |
Add new module to store the progress
This module is used to store the progress of the bootstrap process and
could be used by other applications to get status of virt-bootstrap as
well as percentage of completion.
Convert some info messages to use this new system for a clean reporting
in client applications.
Example usage:
import virtBootstrap
def show_progress(data):
print("Status: %s, Progress: %.2f"
% (data['status'], data['value']))
virtBootstrap.bootstrap(uri='docker://ubuntu', dest="/tmp/test1",
progress_cb=show_progress)
Diffstat (limited to 'src/virtBootstrap/virt_bootstrap.py')
-rwxr-xr-x | src/virtBootstrap/virt_bootstrap.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/virtBootstrap/virt_bootstrap.py b/src/virtBootstrap/virt_bootstrap.py index 460d0e9..f03f29b 100755 --- a/src/virtBootstrap/virt_bootstrap.py +++ b/src/virtBootstrap/virt_bootstrap.py @@ -34,6 +34,7 @@ except ImportError: from urllib.parse import urlparse from virtBootstrap import sources +from virtBootstrap import progress gettext.bindtextdomain("virt-bootstrap", "/usr/share/locale") @@ -87,10 +88,14 @@ def bootstrap(uri, dest, password=None, root_password=None, not_secure=False, - no_cache=False): + no_cache=False, + progress_cb=None): """ Get source object and call unpack method """ + # Get instance of progress storing module + prog = progress.Progress(progress_cb) + uri = urlparse(uri) source = get_source(uri.scheme or 'file') @@ -108,7 +113,8 @@ def bootstrap(uri, dest, username=username, password=password, not_secure=not_secure, - no_cache=no_cache).unpack(dest) + no_cache=no_cache, + progress=prog).unpack(dest) if root_password is not None: set_root_password(dest, root_password) |