diff options
author | Lars Kellogg-Stedman <lars@redhat.com> | 2017-08-29 09:55:48 -0600 |
---|---|---|
committer | Chad Smith <chad.smith@canonical.com> | 2017-08-29 09:55:48 -0600 |
commit | af4630c9846fe979152320035e9cc6c411506503 (patch) | |
tree | 47ef8f33e4b4f8f753a2104e277715454b6ff446 /cloudinit | |
parent | 0ab9859168eb0ba4fc348843e866751cfc67181f (diff) | |
download | vyos-cloud-init-af4630c9846fe979152320035e9cc6c411506503.tar.gz vyos-cloud-init-af4630c9846fe979152320035e9cc6c411506503.zip |
url_helper: fail gracefully if oauthlib is not available
We are unable to ship python-oauthlib in RHEL. This commit allows
imports of url_helper to succeed even when oauthlib is unavailable
and OauthUrlHelper.oauth_headers to raise a NotImplementedException
when called.
LP: #1713760
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/url_helper.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/cloudinit/url_helper.py b/cloudinit/url_helper.py index 7cf76aae..c83061a9 100644 --- a/cloudinit/url_helper.py +++ b/cloudinit/url_helper.py @@ -17,7 +17,11 @@ import time from email.utils import parsedate from functools import partial -import oauthlib.oauth1 as oauth1 +try: + import oauthlib.oauth1 as oauth1 +except ImportError: + oauth1 = None + from requests import exceptions from six.moves.urllib.parse import ( @@ -488,6 +492,10 @@ class OauthUrlHelper(object): def oauth_headers(url, consumer_key, token_key, token_secret, consumer_secret, timestamp=None): + + if oauth1 is None: + raise NotImplementedError('oauth support is not available') + if timestamp: timestamp = str(timestamp) else: |