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): ...@@ -166,19 +166,18 @@ class ImageCollection(Collection):
resp = self.client.api.build(**kwargs) resp = self.client.api.build(**kwargs)
if isinstance(resp, six.string_types): if isinstance(resp, six.string_types):
return self.get(resp) return self.get(resp)
events = list(json_stream(resp)) for chunk in json_stream(resp):
if not events: if 'error' in chunk:
return BuildError('Unknown') raise BuildError(chunk['error'])
for event in events: break
if 'stream' in event: if 'stream' in chunk:
match = re.search(r'(Successfully built |sha256:)([0-9a-f]+)', match = re.search(r'(Successfully built |sha256:)([0-9a-f]+)',
event.get('stream', '')) chunk['stream'])
if match: if match:
image_id = match.group(2) image_id = match.group(2)
return self.get(image_id) return self.get(image_id)
event = events[-1] return BuildError('Unknown')
raise BuildError(event.get('error') or event)
def get(self, name): 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