allow multiline returns from docker for mac

Nothing actually specifies the number of lines the docker api returns,
so we need to allow for more than one line to be returned which this
specfic docker returner does
This commit is contained in:
Daniel Wallace 2016-11-10 09:58:26 -06:00
parent a7e09f9260
commit 74aee1e372

View file

@ -559,6 +559,17 @@ def __virtual__():
return (False, 'Docker module could not get imported')
class DockerJSONDecoder(json.JSONDecoder):
def decode(self, s, _w=None):
objs = []
for line in s.splitlines():
if not line:
continue
obj, _ = self.raw_decode(line)
objs.append(obj)
return objs
def _get_docker_py_versioninfo():
'''
Returns the version_info tuple from docker-py
@ -3459,7 +3470,9 @@ def build(path=None,
.format(image)
)
stream_data = [json.loads(x) for x in response]
stream_data = []
for line in response:
stream_data.extend(json.loads(line, cls=DockerJSONDecoder))
errors = []
# Iterate through API response and collect information
for item in stream_data: