From 4ac431a9a2b6379f9ab663f8a330e2d898e9b077 Mon Sep 17 00:00:00 2001 From: Flaper Fesp Date: Mon, 21 Jan 2013 10:20:06 +0100 Subject: [PATCH] Print useful message when keystoneclient is not installed client.py now prints a useful message when trying to use Auth version 2.0 and keystoneclient is not installed. Fixes bug 1102322 Change-Id: I6ed83610fd6e8c79c2dc5cf05db377a843cab1d5 --- swiftclient/client.py | 12 ++++++++++-- tools/pip-requires | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/swiftclient/client.py b/swiftclient/client.py index a719cef..1ffd1b4 100644 --- a/swiftclient/client.py +++ b/swiftclient/client.py @@ -19,6 +19,7 @@ Cloud Files client library used internally import socket import os +import sys import logging from functools import wraps @@ -240,8 +241,15 @@ def get_keystoneclient_2_0(auth_url, user, key, os_options, **kwargs): insecure = kwargs.get('insecure', False) debug = logger.isEnabledFor(logging.DEBUG) and True or False - from keystoneclient.v2_0 import client as ksclient - from keystoneclient import exceptions + try: + from keystoneclient.v2_0 import client as ksclient + from keystoneclient import exceptions + except ImportError: + sys.exit(''' +Auth version 2.0 requires python-keystoneclient, install it or use Auth +version 1.0 which requires ST_AUTH, ST_USER, and ST_KEY environment +variables to be set or overridden with -A, -U, or -K.''') + try: _ksclient = ksclient.Client(username=user, password=key, diff --git a/tools/pip-requires b/tools/pip-requires index 322630e..60540ac 100644 --- a/tools/pip-requires +++ b/tools/pip-requires @@ -1 +1 @@ -simplejson +simplejson \ No newline at end of file