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
This commit is contained in:
Dan Prince
2012-12-14 09:57:23 -05:00
parent 788bcd4f6e
commit 716fc4b48a

View File

@@ -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