Update unit tests for stream_output to match the behaviour of a docker-py response.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
parent
7e4c3142d7
commit
71ff872e8e
8 changed files with 29 additions and 21 deletions
|
|
@ -5,6 +5,7 @@ import logging
|
|||
import sys
|
||||
from threading import Thread
|
||||
|
||||
import six
|
||||
from docker.errors import APIError
|
||||
from six.moves.queue import Empty
|
||||
from six.moves.queue import Queue
|
||||
|
|
@ -18,7 +19,7 @@ def parallel_execute(objects, obj_callable, msg_index, msg):
|
|||
For a given list of objects, call the callable passing in the first
|
||||
object we give it.
|
||||
"""
|
||||
stream = codecs.getwriter('utf-8')(sys.stdout)
|
||||
stream = get_output_stream()
|
||||
lines = []
|
||||
errors = {}
|
||||
|
||||
|
|
@ -70,6 +71,12 @@ def parallel_execute(objects, obj_callable, msg_index, msg):
|
|||
stream.write("ERROR: for {} {} \n".format(error, errors[error]))
|
||||
|
||||
|
||||
def get_output_stream(stream=sys.stdout):
|
||||
if six.PY3:
|
||||
return stream
|
||||
return codecs.getwriter('utf-8')(stream)
|
||||
|
||||
|
||||
def write_out_msg(stream, lines, msg_index, msg, status="done"):
|
||||
"""
|
||||
Using special ANSI code characters we can write out the msg over the top of
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue