summaryrefslogtreecommitdiff
path: root/cloudinit/url_helper.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@gmail.com>2013-03-13 22:33:18 -0700
committerJoshua Harlow <harlowja@gmail.com>2013-03-13 22:33:18 -0700
commit204e79b93c882e17df63b24f7f682c0dbefb482d (patch)
treeb916cca03675d8c29cf982e80a017fbdfbc874c5 /cloudinit/url_helper.py
parent6ded151bd19d27cd03e22dbf2e98914b12504c78 (diff)
downloadvyos-cloud-init-204e79b93c882e17df63b24f7f682c0dbefb482d.tar.gz
vyos-cloud-init-204e79b93c882e17df63b24f7f682c0dbefb482d.zip
Fix how the http error doesn't always have the response attached
in earlier versions of requests (pre 0.10.8).
Diffstat (limited to 'cloudinit/url_helper.py')
-rw-r--r--cloudinit/url_helper.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/cloudinit/url_helper.py b/cloudinit/url_helper.py
index 08e5f01b..bfc5cfdd 100644
--- a/cloudinit/url_helper.py
+++ b/cloudinit/url_helper.py
@@ -170,7 +170,9 @@ def readurl(url, data=None, timeout=None, retries=0, sec_between=1,
# attrs
return UrlResponse(r)
except exceptions.RequestException as e:
- if isinstance(e, (exceptions.HTTPError)) and e.response:
+ if (isinstance(e, (exceptions.HTTPError))
+ and hasattr(e, 'response') # This appeared in v 0.10.8
+ and e.response):
excps.append(UrlError(e, code=e.response.status_code,
headers=e.response.headers))
else: