diff options
author | Dan Prince <dprince@redhat.com> | 2012-12-14 09:57:23 -0500 |
---|---|---|
committer | Dan Prince <dprince@redhat.com> | 2012-12-14 16:05:30 -0500 |
commit | 716fc4b48a0c4bac1bead46f4c094f9aeac8edf0 (patch) | |
tree | fa5c98c749254cbee9f361fa6e5ba5d3b3b087ae /keystoneclient/client.py | |
parent | 788bcd4f6e5326b739f32c2f552e1bb8c17826a0 (diff) | |
download | python-keystoneclient-716fc4b48a0c4bac1bead46f4c094f9aeac8edf0.tar.gz |
Print to stderr when keyring module is missing.
Updates keystoneclient so that it uses a print statement to
stderr instead of a logger.warn if stderr is a tty.
This works around problems caused by the fact that logging isn't always
initialized when this module import runs (and fails) thus causing:
No handlers could be found for logger "keystoneclient.client"
instead of the intended log message.
Fixes LP Bug #1090396
Change-Id: I94e2c45eec14edfe3c2f356af6907aa827808a13
Diffstat (limited to 'keystoneclient/client.py')
-rw-r--r-- | keystoneclient/client.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/keystoneclient/client.py b/keystoneclient/client.py index b6fd54c..aa70e00 100644 --- a/keystoneclient/client.py +++ b/keystoneclient/client.py @@ -10,6 +10,7 @@ OpenStack Client interface. Handles the REST calls and responses. import copy import logging +import sys import urlparse import httplib2 @@ -38,7 +39,10 @@ try: import keyring import pickle except ImportError: - _logger.warning('Failed to load keyring modules.') + if (hasattr(sys.stderr, 'isatty') and sys.stderr.isatty()): + print >> sys.stderr, 'Failed to load keyring modules.' + else: + _logger.warning('Failed to load keyring modules.') keyring_available = False |