diff options
| author | Steve Baker <sbaker@redhat.com> | 2017-06-01 15:40:44 +1200 |
|---|---|---|
| committer | Steve Baker <sbaker@redhat.com> | 2017-06-02 13:06:17 +1200 |
| commit | 6131fd71b5f58a99ab4a1d85b42143699acd83b5 (patch) | |
| tree | 38a99394f054411034ba356dcbcd86e7d5bbe966 | |
| parent | 21a8681f7b766881c972df2efb80dcc771ad3d49 (diff) | |
| download | kolla-6131fd71b5f58a99ab4a1d85b42143699acd83b5.tar.gz kolla-6131fd71b5f58a99ab4a1d85b42143699acd83b5.zip | |
kolla-build --list-dependencies use json, not pprint
kolla-build --list-dependencies uses pprint, which prints
almost-but-not-quite json. This makes it hard for other tools to parse
its output.
This change switches to a json output with an indent of 2. If there is
interest in a default output which is friendly to both humans and
software, YAML might be more appropriate.
Change-Id: Icaead5a62a2d6510965524f68fb57dcf7494e618
Closes-Bug: #1694888
| -rwxr-xr-x | kolla/image/build.py | 3 | ||||
| -rw-r--r-- | kolla/tests/test_build.py | 7 |
2 files changed, 5 insertions, 5 deletions
diff --git a/kolla/image/build.py b/kolla/image/build.py index 8a153fabd..c8aaa8ff9 100755 --- a/kolla/image/build.py +++ b/kolla/image/build.py @@ -20,7 +20,6 @@ import errno import json import logging import os -import pprint import re import requests import shutil @@ -1029,7 +1028,7 @@ class KollaWorker(object): ancestry = {base.name: []} list_children(base.children, ancestry) - pprint.pprint(ancestry) + json.dump(ancestry, sys.stdout, indent=2) def find_parents(self): """Associate all images with parents and children""" diff --git a/kolla/tests/test_build.py b/kolla/tests/test_build.py index 0591fc127..0c50db98b 100644 --- a/kolla/tests/test_build.py +++ b/kolla/tests/test_build.py @@ -15,6 +15,7 @@ import itertools import mock import os import requests +import sys from kolla.cmd import build as build_cmd from kolla import exception @@ -352,14 +353,14 @@ class KollaWorkerTest(base.TestCase): self.assertRaises(ValueError, kolla.filter_images) - @mock.patch('pprint.pprint') - def test_list_dependencies(self, pprint_mock): + @mock.patch('json.dump') + def test_list_dependencies(self, dump_mock): self.conf.set_override('profile', ['all']) kolla = build.KollaWorker(self.conf) kolla.images = self.images kolla.filter_images() kolla.list_dependencies() - pprint_mock.assert_called_once_with(mock.ANY) + dump_mock.assert_called_once_with(mock.ANY, sys.stdout, indent=2) def test_summary(self): kolla = build.KollaWorker(self.conf) |
