Commit 866e7e7e authored by Furkan Mustafa's avatar Furkan Mustafa

Merge branch '308-fix-cli-output-bug' into 'dev-0.0.9'

Resolve "Error message and progress bar mixed up in cli output"

Closes #308

See merge request !47
parents 9e88ab54 2f1e8c3c
......@@ -93,7 +93,16 @@ class MultipleProgressBar(progressbar.ProgressBar): # pylint: disable=too-many-a
self.update(value)
if self.finish_immediately and self.value == self.max_value:
self.finish()
ProgressbarValues.exist_bars.remove(self)
ProgressbarValues.prevpos = self.position + 1
else:
ProgressbarValues.prevpos = self.position
def finish(self, end='\n', dirty=False):
"""Override finish method from base class ProgressBar.
Finish the progress bar. Remove it from the existing progres bars list.
Update the value of the prevpos field of ProgressbarValues class.
"""
if self._finished:
return
progressbar.ProgressBar.finish(self, end=end, dirty=dirty)
ProgressbarValues.exist_bars.remove(self)
ProgressbarValues.prevpos = self.position + 1
......@@ -109,6 +109,10 @@ async def _pull_with_progress_distributed(ctx, imagename, node, force):
async for data in json_streamer(resp.content, '$.progress[::]'):
resp_err = data.get('error')
if resp_err:
for progbar in list(progbars.values()):
progbar['bar'].finish(dirty=True)
if lastbar:
lastbar.seek_last_line()
click.echo('An error occured while pulling the image. {}'.format(resp_err))
return 1
if data.get('finished'):
......
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