diff options
-rw-r--r-- | sos/plugins/__init__.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py index c87ae19b..6c3b153e 100644 --- a/sos/plugins/__init__.py +++ b/sos/plugins/__init__.py @@ -746,9 +746,10 @@ class Plugin(object): def add_string_as_file(self, content, filename): """Add a string to the archive as a file named `filename`""" self.copy_strings.append((content, filename)) - content = content.splitlines()[0] - if not isinstance(content, six.string_types): - content = content.decode('utf8', 'ignore') + if content: + content = content.splitlines()[0] + if not isinstance(content, six.string_types): + content = content.decode('utf8', 'ignore') self._log_debug("added string ...'%s' as '%s'" % (content, filename)) def get_cmd_output_now(self, exe, suggest_filename=None, @@ -948,9 +949,11 @@ class Plugin(object): def _collect_strings(self): for string, file_name in self.copy_strings: - content = string.splitlines()[0] - if not isinstance(content, six.string_types): - content = content.decode('utf8', 'ignore') + content = '' + if string: + content = string.splitlines()[0] + if not isinstance(content, six.string_types): + content = content.decode('utf8', 'ignore') self._log_info("collecting string ...'%s' as '%s'" % (content, file_name)) try: |