diff options
author | Ben Hutchings <ben.hutchings@codethink.co.uk> | 2020-05-06 13:26:12 +0100 |
---|---|---|
committer | Ben Hutchings <ben.hutchings@codethink.co.uk> | 2020-05-06 13:30:28 +0100 |
commit | c5f92b037208f4ffd96cadc2acbcaafce8bf858e (patch) | |
tree | abecb65401301a92de649e24133a74cd31db7f3b /lorrycontroller | |
parent | 1dd8feaee55c5f530528b59019a2ad3c357f2905 (diff) | |
download | lorry-controller-c5f92b037208f4ffd96cadc2acbcaafce8bf858e.tar.gz |
Convert output from runcmd{,_unchecked} to text
The cliapp.Application.runcmd{,_unchecked} methods return bytes
objects under Python 3. Decode these as UTF-8 in non-strict (replace)
mode.
Diffstat (limited to 'lorrycontroller')
-rw-r--r-- | lorrycontroller/gerrit.py | 5 | ||||
-rw-r--r-- | lorrycontroller/gitano.py | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/lorrycontroller/gerrit.py b/lorrycontroller/gerrit.py index 042a621..6ae24e3 100644 --- a/lorrycontroller/gerrit.py +++ b/lorrycontroller/gerrit.py @@ -34,7 +34,10 @@ class Gerrit(object): '%s@%s' % (user, host)] def _ssh_command(self, command): - return cliapp.runcmd(self._ssh_command_args + command) + out = cliapp.runcmd(self._ssh_command_args + command) + if isinstance(out, bytes): + out = out.decode('utf-8', errors='replace') + return out def has_project(self, name): # There's no 'does this project exist' command in Gerrit 2.9.4; 'list diff --git a/lorrycontroller/gitano.py b/lorrycontroller/gitano.py index d0d1a0c..b5b860c 100644 --- a/lorrycontroller/gitano.py +++ b/lorrycontroller/gitano.py @@ -91,6 +91,9 @@ class GitanoCommand(object): exit, stdout, stderr = cliapp.runcmd_unchecked( base_argv + quoted_args) + if isinstance(stdout, bytes): + stdout = stdout.decode('utf-8', errors='replace') + stderr = stderr.decode('utf-8', errors='replace') if exit != 0: logging.error( |