aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2014-02-11 16:53:16 +0000
committerBryn M. Reeves <bmr@redhat.com>2014-02-11 16:53:16 +0000
commitc48b762c2e98ee05a17375af7427af702f9c9925 (patch)
treef87bcececa2211ce4c8d29585e96e9f10837584f
parent7f6d34d154b9fe110c168a5b44083d8e35bb2068 (diff)
downloadsos-c48b762c2e98ee05a17375af7427af702f9c9925.tar.gz
Fix command output substitution exception
If a comand has a substitution registered via do_cmd_output_sub() but no data was collected (e.g. command not found) the postproc code will throw an exception as the return value ('replacements') is never assigned. Initialise replacements to None before scanning the list of run commands and return this if no substitutions were made. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/__init__.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index 7130c7ad..9b643aba 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -181,6 +181,7 @@ class Plugin(object):
if not self.executed_commands:
return 0
+ replacements = None
try:
for called in self.executed_commands:
# was anything collected?
@@ -194,12 +195,12 @@ class Plugin(object):
regexp, subst, readable.read())
if replacements:
self.archive.add_string(result, path)
- else:
- replacements = 0
+
except Exception as e:
msg = 'regex substitution failed for %s in plugin %s with: "%s"'
self.soslog.error(msg % (called['exe'], self.name(), e))
- replacements = 0
+ replacements = None
+
if self.commons['cmdlineopts'].profiler:
time_passed = time() - start_time
self.proflog.debug("subst: %-75s time: %f"