From c5f92b037208f4ffd96cadc2acbcaafce8bf858e Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Wed, 6 May 2020 13:26:12 +0100 Subject: 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. --- lorry-controller-minion | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lorry-controller-minion') diff --git a/lorry-controller-minion b/lorry-controller-minion index 0412629..4f3069e 100755 --- a/lorry-controller-minion +++ b/lorry-controller-minion @@ -298,6 +298,9 @@ class MINION(cliapp.Application): def disk_usage_by_dir(self, dirname): exit, out, err = cliapp.runcmd_unchecked(['du', '-sk', dirname]) + if isinstance(out, bytes): + out = out.decode('utf-8', errors='replace') + err = err.decode('utf-8', errors='replace') if exit: logging.error('du -sk %s failed: %r', dirname, err) return 0 -- cgit v1.2.1