Merge "Work better in server env with no keyrings"
This commit is contained in:
@@ -33,17 +33,17 @@ from keystoneclient import exceptions
|
|||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# keyring init
|
def try_import_keyring():
|
||||||
keyring_available = True
|
|
||||||
try:
|
try:
|
||||||
import keyring
|
import keyring
|
||||||
import pickle
|
import pickle
|
||||||
|
return True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
if (hasattr(sys.stderr, 'isatty') and sys.stderr.isatty()):
|
if (hasattr(sys.stderr, 'isatty') and sys.stderr.isatty()):
|
||||||
print >> sys.stderr, 'Failed to load keyring modules.'
|
print >> sys.stderr, 'Failed to load keyring modules.'
|
||||||
else:
|
else:
|
||||||
_logger.warning('Failed to load keyring modules.')
|
_logger.warning('Failed to load keyring modules.')
|
||||||
keyring_available = False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class HTTPClient(object):
|
class HTTPClient(object):
|
||||||
@@ -121,7 +121,7 @@ class HTTPClient(object):
|
|||||||
requests.logging.getLogger(requests.__name__).addHandler(ch)
|
requests.logging.getLogger(requests.__name__).addHandler(ch)
|
||||||
|
|
||||||
# keyring setup
|
# keyring setup
|
||||||
self.use_keyring = use_keyring and keyring_available
|
self.use_keyring = use_keyring and try_import_keyring()
|
||||||
self.force_new_token = force_new_token
|
self.force_new_token = force_new_token
|
||||||
self.stale_duration = stale_duration or access.STALE_TOKEN_DURATION
|
self.stale_duration = stale_duration or access.STALE_TOKEN_DURATION
|
||||||
self.stale_duration = int(self.stale_duration)
|
self.stale_duration = int(self.stale_duration)
|
||||||
|
Reference in New Issue
Block a user