mirror of
https://github.com/clearlinux/autospec.git
synced 2026-08-25 01:06:43 +00:00
Checking return code after download
Function really_download in tarball.py does not handle http server codes that can be interpreted as errors i.e. 404 501. When there is no failure returned in a 404 response the 404 page contents are saved as the tarball. This change adds code to test that the response from the server is 200. Any redirection is handled by pycurl internaly and the code that is checked is the code that the server with the response returns to autospec. Signed-off-by: Alex Jaramillo <alex.v.jaramillo@intel.com>
This commit is contained in:
committed by
William Douglas
parent
f319b6ad44
commit
8ae356f803
@@ -63,6 +63,11 @@ def really_download(upstream_url, destination):
|
||||
c.setopt(c.FOLLOWLOCATION, True)
|
||||
try:
|
||||
c.perform()
|
||||
code = c.getinfo(pycurl.HTTP_CODE)
|
||||
if code != 200:
|
||||
print_fatal("get request to {} returned {}".format(upstream_url, code))
|
||||
os.remove(destination)
|
||||
exit(1)
|
||||
except pycurl.error as excep:
|
||||
print_fatal("unable to download {}: {}".format(upstream_url, excep))
|
||||
os.remove(destination)
|
||||
|
||||
Reference in New Issue
Block a user