From 716fc4b48a0c4bac1bead46f4c094f9aeac8edf0 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Fri, 14 Dec 2012 09:57:23 -0500 Subject: [PATCH] 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 --- keystoneclient/client.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/keystoneclient/client.py b/keystoneclient/client.py index b6fd54cb2..aa70e00fe 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