Fix build against the swarm cluster by joining buffered output before parsing json.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
fe65c0258d
commit
3661e8bc74
7 changed files with 49 additions and 37 deletions
|
|
@ -7,7 +7,6 @@ import platform
|
|||
import ssl
|
||||
import subprocess
|
||||
|
||||
import six
|
||||
from docker import version as docker_py_version
|
||||
from six.moves import input
|
||||
|
||||
|
|
@ -36,31 +35,6 @@ def yesno(prompt, default=None):
|
|||
return None
|
||||
|
||||
|
||||
def split_buffer(reader, separator):
|
||||
"""
|
||||
Given a generator which yields strings and a separator string,
|
||||
joins all input, splits on the separator and yields each chunk.
|
||||
|
||||
Unlike string.split(), each chunk includes the trailing
|
||||
separator, except for the last one if none was found on the end
|
||||
of the input.
|
||||
"""
|
||||
buffered = six.text_type('')
|
||||
separator = six.text_type(separator)
|
||||
|
||||
for data in reader:
|
||||
buffered += data.decode('utf-8')
|
||||
while True:
|
||||
index = buffered.find(separator)
|
||||
if index == -1:
|
||||
break
|
||||
yield buffered[:index + 1]
|
||||
buffered = buffered[index + 1:]
|
||||
|
||||
if len(buffered) > 0:
|
||||
yield buffered
|
||||
|
||||
|
||||
def call_silently(*args, **kwargs):
|
||||
"""
|
||||
Like subprocess.call(), but redirects stdout and stderr to /dev/null.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue