Kaydet (Commit) a164f466 authored tarafından Aaron Cowdin's avatar Aaron Cowdin

Better error handling, itterate on json stream directly.

Signed-off-by: 's avatarAaron Cowdin <aaron.cowdin@gmail.com>
üst 7dffc462
......@@ -166,19 +166,18 @@ class ImageCollection(Collection):
resp = self.client.api.build(**kwargs)
if isinstance(resp, six.string_types):
return self.get(resp)
events = list(json_stream(resp))
if not events:
return BuildError('Unknown')
for event in events:
if 'stream' in event:
for chunk in json_stream(resp):
if 'error' in chunk:
raise BuildError(chunk['error'])
break
if 'stream' in chunk:
match = re.search(r'(Successfully built |sha256:)([0-9a-f]+)',
event.get('stream', ''))
chunk['stream'])
if match:
image_id = match.group(2)
return self.get(image_id)
event = events[-1]
raise BuildError(event.get('error') or event)
return BuildError('Unknown')
def get(self, name):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment