canonical/pycloudlib

Can't use `.execute` expecting non-utf-8 output

Opened this issue · 1 comments

The instance execute method calls ends up (in _ssh) calling .decode('utf-8') in the output of the command which is executed. Because decode is being strict, this raises an error if the command returns non-utf-8.

Although I understand UTF-8 can be the default decoder, we could make use of an option either to ignore/replace errors, or to specify a different decoder.

The instance execute method calls ends up (in _ssh) calling .decode('utf-8') in the output of the command which is executed. Because decode is being strict, this raises an error if the command returns non-utf-8.

Although I understand UTF-8 can be the default decoder, we could make use of an option either to ignore/replace errors, or to specify a different decoder.

Related (but different) is that pycloudlib mangles some shell commands which contain quotes - this can be worked around by writing a file which contains a shell script and then using .execute() to execute the script (which might also work around the utf-8 issue, not sure).

Non-utf-8 input and quotes in strings are not uncommon use cases and this is a heavily used method of pycloudlib. I think that we should make these "just work" without workarounds.