diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2017-03-29 12:29:46 +0100 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2017-03-31 15:54:02 +0100 |
commit | 7ba2fb47d05b608f3863fda9271894e38b43937a (patch) | |
tree | bc983630eb2c3578d8997a519f41fe12f52801c0 | |
parent | 8df3d15015796001845c676fc2606a9803da684d (diff) | |
download | sos-7ba2fb47d05b608f3863fda9271894e38b43937a.tar.gz |
[jars] fix maven_id dictionary encoding
The dictionary must contain string types, not byte arrays.
Causes an exception when packing strings with Python3:
[sos.sosreport:setup] executing 'sosreport -vvv --batch --debug -o jars'
Setting up plugins ...
Traceback (most recent call last):
File "./sosreport", line 25, in <module>
main(sys.argv[1:])
File "/home/breeves/src/git/sos/sos/sosreport.py", line 1632, in main
sos.execute()
TypeError: key b'version' is not a string
Resolves: #984.
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r-- | sos/plugins/__init__.py | 12 | ||||
-rw-r--r-- | sos/plugins/jars.py | 4 |
2 files changed, 13 insertions, 3 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py index 46f9cb83..5286e4b5 100644 --- a/sos/plugins/__init__.py +++ b/sos/plugins/__init__.py @@ -671,7 +671,11 @@ 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]).decode('utf8', 'ignore') + if isinstance(content, six.string_types): + content = "..." + content.splitlines()[0] + else: + content = ("..." + + (content.splitlines()[0]).decode('utf8', 'ignore')) self._log_debug("added string '%s' as '%s'" % (content, filename)) def get_cmd_output_now(self, exe, suggest_filename=None, @@ -824,7 +828,11 @@ class Plugin(object): def _collect_strings(self): for string, file_name in self.copy_strings: content = "..." - content += (string.splitlines()[0]).decode('utf8', 'ignore') + if isinstance(string, six.string_types): + content = "..." + content.splitlines()[0] + else: + content = ("..." + + (content.splitlines()[0]).decode('utf8', 'ignore')) self._log_info("collecting string '%s' as '%s'" % (content, file_name)) try: diff --git a/sos/plugins/jars.py b/sos/plugins/jars.py index fd879139..6c15eff3 100644 --- a/sos/plugins/jars.py +++ b/sos/plugins/jars.py @@ -113,7 +113,9 @@ class Jars(Plugin, RedHatPlugin): if not line.startswith(b"#"): try: (key, value) = line.split(b"=") - props[key.strip()] = value.strip() + key = key.decode('utf8').strip() + value = value.decode('utf8').strip() + props[key] = value except ValueError: return None except IOError: |