summaryrefslogtreecommitdiff
path: root/glanceclient/v1
diff options
context:
space:
mode:
authorLouis Taylor <kragniz@gmail.com>2014-12-16 17:59:28 +0000
committerLouis Taylor <kragniz@gmail.com>2015-01-06 10:36:01 +0000
commit90543244423692cade8673cf78fa601c9af04f1c (patch)
treeca37c59777cb0cf3df1b29fa03f8d870f26cb8fa /glanceclient/v1
parentdf02ee8e2a10d2f37a9c013dec157c88b8dce49d (diff)
downloadpython-glanceclient-90543244423692cade8673cf78fa601c9af04f1c.tar.gz
Disable progress bar if image is piped into client
Previously, running: cat something.img | glance image-create --progress --container-format=bare --disk-format=raw or cat something.img | glance --os-image-api-version 2 image-upload --progress <image id> would result in an error. This error was caused by the length of the input being unknown, so the overall progress cannot be found. This patch disables the progress bar whenever the size of the input file cannot be determined. Change-Id: I6bfef7441864b638194126880241cc2c96d5b18b Closes-Bug: #1402746
Diffstat (limited to 'glanceclient/v1')
-rw-r--r--glanceclient/v1/shell.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/glanceclient/v1/shell.py b/glanceclient/v1/shell.py
index d4d117e..a7888f9 100644
--- a/glanceclient/v1/shell.py
+++ b/glanceclient/v1/shell.py
@@ -225,9 +225,12 @@ def do_image_create(gc, args):
# Only show progress bar for local image files
if fields.get('data') and args.progress:
filesize = utils.get_file_size(fields['data'])
- fields['data'] = progressbar.VerboseFileWrapper(
- fields['data'], filesize
- )
+ if filesize is not None:
+ # NOTE(kragniz): do not show a progress bar if the size of the
+ # input is unknown (most likely a piped input)
+ fields['data'] = progressbar.VerboseFileWrapper(
+ fields['data'], filesize
+ )
image = gc.images.create(**fields)
_image_show(image, args.human_readable)