Pretty-print HTTP errors when downloading a file.

This commit is contained in:
Jukka Jylänki
2013-09-05 16:52:01 +03:00
parent dd93abdc6d
commit 0065fd3bc0

4
emsdk
View File

@@ -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: if os.path.exists(file_name) and not download_even_if_exists:
print "File '" + file_name + "' already downloaded, skipping." print "File '" + file_name + "' already downloaded, skipping."
return True return True
try:
u = urllib2.urlopen(url) u = urllib2.urlopen(url)
mkdir_p(os.path.dirname(file_name)) mkdir_p(os.path.dirname(file_name))
f = open(file_name, 'wb') f = open(file_name, 'wb')
@@ -135,6 +136,9 @@ def download_file(url, dstpath, download_even_if_exists=False):
print status, print status,
f.close() f.close()
except urllib2.HTTPError, e:
print "HTTP error with URL '" + url + "': " + str(e)
return False
return True return True
def run_get_output(cmd, cwd=None): def run_get_output(cmd, cwd=None):