Pretty-print HTTP errors when downloading a file.
This commit is contained in:
4
emsdk
4
emsdk
@@ -114,6 +114,7 @@ def download_file(url, dstpath, download_even_if_exists=False):
|
||||
if os.path.exists(file_name) and not download_even_if_exists:
|
||||
print "File '" + file_name + "' already downloaded, skipping."
|
||||
return True
|
||||
try:
|
||||
u = urllib2.urlopen(url)
|
||||
mkdir_p(os.path.dirname(file_name))
|
||||
f = open(file_name, 'wb')
|
||||
@@ -135,6 +136,9 @@ def download_file(url, dstpath, download_even_if_exists=False):
|
||||
print status,
|
||||
|
||||
f.close()
|
||||
except urllib2.HTTPError, e:
|
||||
print "HTTP error with URL '" + url + "': " + str(e)
|
||||
return False
|
||||
return True
|
||||
|
||||
def run_get_output(cmd, cwd=None):
|
||||
|
||||
Reference in New Issue
Block a user