From 1672d26505b76fc708f015377343c1e1ee2fffb4 Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Fri, 4 Jul 2014 18:36:49 +0100 Subject: [PATCH] [plugin] backport collectExtOutputs and addCopySpecs Backport the plural collection methods from upstream. This simplifies plugin backports (simple search-and-replace rather than converting a list argument into multiple function calls). --- sos/plugintools.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/sos/plugintools.py b/sos/plugintools.py index 6b02fa5..81cca18 100644 --- a/sos/plugintools.py +++ b/sos/plugintools.py @@ -371,6 +371,12 @@ class PluginBase: self.collectExtOutput("tail -c%d %s" % (sizelimit, flog), "tail_" + os.path.basename(flog), flog[1:]) + def addCopySpecs(self, copyspecs): + if isinstance(copyspecs, basestring): + raise TypeError("addCopySpecs called with string argument") + for copyspec in copyspecs: + self.addCopySpec(copyspec) + def addCopySpec(self, copyspec): """ Add a file specification (can be file, dir,or shell glob) to be copied into the sosreport by this module @@ -383,10 +389,6 @@ class PluginBase: if filespec not in self.copyPaths: self.copyPaths.append(filespec) - def addCopySpecs(self, copyspecs): - for copyspec in copyspecs: - self.addCopySpec(copyspec) - def callExtProg(self, prog): """ Execute a command independantly of the output gathering part of sosreport @@ -397,6 +399,13 @@ class PluginBase: self.soslog.info("could not run '%s'" % prog) return (status, shout, runtime) + def collectExtOutputs(self, cmds): + """Run a list of programs and collect the output""" + if isinstance(cmds, basestring): + raise TypeError("collectExtOutputs called with string argument") + for cmd in cmds: + self.collectExtOutput(cmd) + def collectExtOutput(self, exe, suggest_filename = None, symlink = None, timeout = 300): """ Run a program and collect the output -- 1.9.3