Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Solve Print Errors (Decode) #141

Closed
imjoseangel opened this issue Oct 8, 2021 · 1 comment · Fixed by #142
Closed

Solve Print Errors (Decode) #141

imjoseangel opened this issue Oct 8, 2021 · 1 comment · Fixed by #142

Comments

@imjoseangel
Copy link
Contributor

During tests in #125 we have detected that the line

                    try:
                        running = kube_obj.get_from_cluster(config["kubeconfig"], config["context"])
                    except subprocess.CalledProcessError as e:
                        printer.diff(path, Difference(e.output, None))
                        differences += 1
                        continue

prints:

b'Error from server (NotFound): services "kubediff-app" not found\n'

And not:

Error from server (NotFound): services "kubediff-app" not found

We need to solve it adding decode:

printer.diff(path, Difference(e.output.decode('utf-8'), None))
@imjoseangel imjoseangel self-assigned this Oct 8, 2021
@imjoseangel imjoseangel removed their assignment Oct 8, 2021
@imjoseangel imjoseangel added this to the python3 milestone Oct 8, 2021
@imjoseangel
Copy link
Contributor Author

This will fix also the error:

Traceback (most recent call last):
  File "/Users/imjoseangel/source/imjoseangel/kubediff/kubediff", line 98, in <module>
    main()
  File "/Users/imjoseangel/source/imjoseangel/kubediff/kubediff", line 92, in main
    failed = check_files(options.args.paths, printer, config)
  File "/Users/imjoseangel/Documents/source/imjoseangel/kubediff/kubedifflib/_diff.py", line 271, in check_files
    printer.finish()
  File "/Users/imjoseangel/Documents/source/imjoseangel/kubediff/kubedifflib/_diff.py", line 254, in finish
    print(json.dumps(self.data, sort_keys=True, indent=2, separators=(',', ': ')))
  File "/Users/imjoseangel/.pyenv/versions/3.9.7/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 234, in dumps
    return cls(
  File "/Users/imjoseangel/.pyenv/versions/3.9.7/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/Users/imjoseangel/.pyenv/versions/3.9.7/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/Users/imjoseangel/.pyenv/versions/3.9.7/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/Users/imjoseangel/.pyenv/versions/3.9.7/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "/Users/imjoseangel/.pyenv/versions/3.9.7/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/Users/imjoseangel/.pyenv/versions/3.9.7/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type bytes is not JSON serializable

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant