Bug: The log stream from docker can be str or bytes

We don't know why this is the case..
This commit is contained in:
Einar Forselv 2019-12-06 07:30:39 +01:00
parent 216202dec7
commit cfc92b2284
1 changed files with 7 additions and 1 deletions

View File

@ -35,7 +35,13 @@ def run(image: str = None, command: str = None, volumes: dict = None,
line = "" line = ""
while True: while True:
try: try:
line += next(stream).decode() # TODO: figure out why..
# Apparently the stream can be bytes or strings.
data = next(stream)
if isinstance(data, bytes):
line += data.decode()
elif isinstance(data, str):
line += data
if line.endswith('\n'): if line.endswith('\n'):
break break
except StopIteration: except StopIteration: