Ensure that a download failure is properly raised before the read fails
Without this change, a download failure may bail out with the message: "Failure downloading http://foo/bar, 'NoneType' object has no attribute 'read'" whereas with this fix, you'd get a proper error like: "Failure downloading http://foo/bar, Request failed: <urlopen error [Errno 113] No route to host>" or one of the many other possible download errors that can occur.
This commit is contained in:
parent
b4bab770f6
commit
20b7757032
1 changed files with 3 additions and 0 deletions
|
@ -282,6 +282,9 @@ def main():
|
||||||
package = os.path.join(tempdir, str(src.rsplit('/', 1)[1]))
|
package = os.path.join(tempdir, str(src.rsplit('/', 1)[1]))
|
||||||
try:
|
try:
|
||||||
rsp, info = fetch_url(module, src)
|
rsp, info = fetch_url(module, src)
|
||||||
|
# If download fails, raise a proper exception
|
||||||
|
if rsp is None:
|
||||||
|
raise Exception(info['msg'])
|
||||||
f = open(package, 'w')
|
f = open(package, 'w')
|
||||||
# Read 1kb at a time to save on ram
|
# Read 1kb at a time to save on ram
|
||||||
while True:
|
while True:
|
||||||
|
|
Loading…
Reference in a new issue