ExecContext: Fix output handling #9
1 changed files with 6 additions and 1 deletions
lib.Result.__repr__(): Fix binary stdout exception
__repr__() tries to decode binary stdout as string and fails without a backup. Fix that.
Signed-off-by: Jan Lindemann <jan@janware.com>
commit
9732b48788
|
|
@ -44,7 +44,12 @@ class Result:
|
||||||
if self.__stdout is None:
|
if self.__stdout is None:
|
||||||
ret = ''
|
ret = ''
|
||||||
else:
|
else:
|
||||||
ret = self.stdout_str[:20]
|
max_len = 40
|
||||||
|
try:
|
||||||
|
ret = self.stdout_str[:max_len]
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
chunk = self.__stdout[:max_len]
|
||||||
|
ret = ''.join(chr(b) if 32 <= b <= 126 else '.' for b in chunk)
|
||||||
if quote:
|
if quote:
|
||||||
ret = f'"{ret}"'
|
ret = f'"{ret}"'
|
||||||
return ret
|
return ret
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue