Show a pretty progressbar when uploading and downloading an image.
Add a new module that contain generic wrapper for file and iterator, which are used to wrap image to upload and the request body iterator in upload and download cases repectively, to show and advance a pretty progress bar when this laters are consumed, The progress bar is triggered by adding a --progress command line argument to commands: image-create, image-download or image-update. Change-Id: I2ba42fd0c58f4fa087adb568ec3f08246cae3759 bug fix: LP#1112309 blueprint: progressbar-when-uploading
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from glanceclient.common import progressbar
|
||||
from glanceclient.common import utils
|
||||
from glanceclient import exc
|
||||
|
||||
@@ -125,9 +126,13 @@ def do_explain(gc, args):
|
||||
'If this is not specified the image data will be '
|
||||
'written to stdout.')
|
||||
@utils.arg('id', metavar='<IMAGE_ID>', help='ID of image to download.')
|
||||
@utils.arg('--progress', action='store_true', default=False,
|
||||
help='Show download progress bar.')
|
||||
def do_image_download(gc, args):
|
||||
"""Download a specific image."""
|
||||
body = gc.images.data(args.id)
|
||||
if args.progress:
|
||||
body = progressbar.VerboseIteratorWrapper(body, len(body))
|
||||
utils.save_image(body, args.file)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user