Get better format for long lines with PrettyTable

Based on current implement, the cli output format will be bad if
the lines are too long. This issue can be fixed by setting 'max_width'.
However, there is a bug against it, see
https://code.google.com/p/prettytable/source/browse/trunk/CHANGELOG?r=85
line 3. So the requirements.txt is updated as well.

docImpact
Fixes bug 1251283

Change-Id: I0d4192ad9d10a3d6d47a8319463a5edb57719a68
This commit is contained in:
Fei Long Wang
2013-11-15 16:02:46 +08:00
parent 80cf47e229
commit 336feeb523
5 changed files with 28 additions and 14 deletions
+6 -3
View File
@@ -108,7 +108,7 @@ def do_image_list(gc, args):
utils.print_list(images, columns)
def _image_show(image, human_readable=False):
def _image_show(image, human_readable=False, max_column_width=80):
# Flatten image properties dict for display
info = copy.deepcopy(image._info)
if human_readable:
@@ -116,7 +116,7 @@ def _image_show(image, human_readable=False):
for (k, v) in info.pop('properties').iteritems():
info['Property \'%s\'' % k] = v
utils.print_dict(info)
utils.print_dict(info, max_column_width=max_column_width)
def _set_data_field(fields, args):
@@ -127,11 +127,14 @@ def _set_data_field(fields, args):
@utils.arg('image', metavar='<IMAGE>', help='Name or ID of image to describe.')
@utils.arg('--human-readable', action='store_true', default=False,
help='Print image size in a human-friendly format.')
@utils.arg('--max-column-width', metavar='<integer>', default=80,
help='The max column width of the printed table.')
def do_image_show(gc, args):
"""Describe a specific image."""
image_id = utils.find_resource(gc.images, args.image).id
image = gc.images.get(image_id)
_image_show(image, args.human_readable)
_image_show(image, args.human_readable,
max_column_width=int(args.max_column_width))
@utils.arg('--file', metavar='<FILE>',