diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2018-12-12 10:36:09 +0000 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2018-12-13 10:58:51 +0000 |
commit | 9135d767e6244d370d8cbd59a75e1a56b928d4a3 (patch) | |
tree | c7b31111c94ed35bf6b69c121f63cec641c53309 | |
parent | 55a21b9ef43d596a797325379b8acd3100850b50 (diff) | |
download | sos-9135d767e6244d370d8cbd59a75e1a56b928d4a3.tar.gz |
[composer] avoid running 'blueprints list' twice
Use get_cmd_output_now() to store the first call to composer-cli's
'blueprints list' command in the report, and then use that file to
find the list of available blueprints.
Related: #1447
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r-- | sos/plugins/composer.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/sos/plugins/composer.py b/sos/plugins/composer.py index 34901bce..ff3aa49b 100644 --- a/sos/plugins/composer.py +++ b/sos/plugins/composer.py @@ -12,11 +12,11 @@ class Composer(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin): def _get_blueprints(self): blueprints = [] - bp_result = self.get_command_output("composer-cli blueprints list") - if bp_result['status'] != 0: - return blueprints - for line in bp_result['output'].splitlines(): - blueprints.append(line) + bp_file = self.get_cmd_output_now("composer-cli blueprints list") + if bp_file: + with open(bp_file, "r") as bps: + for line in bps.read().splitlines(): + blueprints.append(line) return blueprints def setup(self): @@ -31,9 +31,6 @@ class Composer(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin): for blueprint in blueprints: self.add_cmd_output("composer-cli blueprints show %s" % blueprint) - self.add_cmd_output([ - "composer-cli blueprints list", - "composer-cli sources list" - ]) + self.add_cmd_output("composer-cli sources list") # vim: set et ts=4 sw=4 : |