From 9135d767e6244d370d8cbd59a75e1a56b928d4a3 Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Wed, 12 Dec 2018 10:36:09 +0000 Subject: [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 --- sos/plugins/composer.py | 15 ++++++--------- 1 file 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 : -- cgit