Skip to content

Commit

Permalink
Added error handling
Browse files Browse the repository at this point in the history
Added verbosity when the download of a layer fails.
For example, error can happen if the session times out.
  • Loading branch information
NotGlop authored Jun 19, 2019
1 parent e53d154 commit 7a37ca0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docker_pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
print ublob[7:19] + ': Downloading...',
sys.stdout.flush()
bresp = requests.get('https://registry-1.docker.io/v2/{}/blobs/{}'.format(repository, ublob), headers=auth_head, verify=False)
if (bresp.status_code != 200):
print '\rERROR: Cannot download layer {} [HTTP {}]'.format(ublob[7:19], bresp.status_code, bresp.headers['Content-Length'])
print bresp.content
exit(1)
print "\r{}: Pull complete [{}]".format(ublob[7:19], bresp.headers['Content-Length'])
content[0]['Layers'].append(fake_layerid + '/layer.tar')
file = open(layerdir + '/layer.tar', "wb")
Expand Down

0 comments on commit 7a37ca0

Please sign in to comment.