def push_image(client, dest_repo, dest_tag): bar = Bar() results = client.images.push(dest_repo, dest_tag, stream=True, decode=True) print('') for result in results: status = result.get('status') if 'id' in result: if status == 'Pushing': output = '{id}: {status} {progress}'.format(**result) bar.writeln(output) elif status == 'Pushed': bar.clearln() print('{id}: {status}'.format(**result)) bar.finish() bar.clearln()
def pull_image(client, src): src_repo, src_tag = split_tag(src) bar = Bar() results = client.api.pull(src_repo, src_tag, stream=True, decode=True) print('') for result in results: status = result.get('status') if 'id' in result: if status == 'Downloading' or status == 'Extracting': output = '{id}: {status} {progress}'.format(**result) bar.writeln(output) elif status == 'Download complete' or status == 'Pull complete': bar.clearln() print('{id}: {status}'.format(**result)) bar.finish() bar.clearln() return client.images.get(src)