sailesh1993 / rpms / cloud-init

Forked from rpms/cloud-init a year ago
Clone
ef3f20
From 949f87447031d8d83b8108aaa11046eb8a50650b Mon Sep 17 00:00:00 2001
ef3f20
From: Lars Kellogg-Stedman <lars@redhat.com>
ef3f20
Date: Thu, 8 Dec 2016 15:24:24 -0500
ef3f20
Subject: [PATCH] url_helper: fail gracefully if oauthlib is not available
ef3f20
ef3f20
We are unable to ship python-oauthlib in RHEL.  Allow imports of
ef3f20
url_helper to succeed even when oauthlib is unavailable.
ef3f20
ef3f20
X-downstream-only: true
ef3f20
---
ef3f20
 cloudinit/url_helper.py | 10 +++++++++-
ef3f20
 1 file changed, 9 insertions(+), 1 deletion(-)
ef3f20
ef3f20
diff --git a/cloudinit/url_helper.py b/cloudinit/url_helper.py
ef3f20
index 312b046..19c8148 100644
ef3f20
--- a/cloudinit/url_helper.py
ef3f20
+++ b/cloudinit/url_helper.py
ef3f20
@@ -17,7 +17,11 @@ import time
ef3f20
 from email.utils import parsedate
ef3f20
 from functools import partial
ef3f20
 
ef3f20
-import oauthlib.oauth1 as oauth1
ef3f20
+try:
ef3f20
+    import oauthlib.oauth1 as oauth1
ef3f20
+except ImportError:
ef3f20
+    oauth1 = None
ef3f20
+
ef3f20
 from requests import exceptions
ef3f20
 
ef3f20
 from six.moves.urllib.parse import (
ef3f20
@@ -481,6 +485,10 @@ class OauthUrlHelper(object):
ef3f20
 
ef3f20
 def oauth_headers(url, consumer_key, token_key, token_secret, consumer_secret,
ef3f20
                   timestamp=None):
ef3f20
+
ef3f20
+    if oauth1 is None:
ef3f20
+        raise NotImplementedError('oauth support is not available')
ef3f20
+
ef3f20
     if timestamp:
ef3f20
         timestamp = str(timestamp)
ef3f20
     else: