diff options
| author | Brian Waldon <bcwaldon@gmail.com> | 2012-07-29 21:08:26 -0700 |
|---|---|---|
| committer | Brian Waldon <bcwaldon@gmail.com> | 2012-07-29 21:21:29 -0700 |
| commit | 158f7ccd743b9fee12d60b10cf0fe696d5d4ed34 (patch) | |
| tree | c9259c54b14228adda73cb57a1e3f75c5ab17a5f | |
| parent | 1e744f162ece85f14120a16180ed0f83fe9f1e09 (diff) | |
| download | python-glanceclient-158f7ccd743b9fee12d60b10cf0fe696d5d4ed34.tar.gz | |
Fix --debug CLI option
The --debug argument has been ignored since httplib2 was replaced
with httplib. This re-enables the --debug flag as an equivalent
to the env var GLANCECLIENT_DEBUG.
Fixes bug 1030700
Change-Id: Ib653049eea2f18c4cc2f8f8aac7884245afd0f04
| -rw-r--r-- | glanceclient/common/http.py | 8 | ||||
| -rw-r--r-- | glanceclient/shell.py | 9 |
2 files changed, 7 insertions, 10 deletions
diff --git a/glanceclient/common/http.py b/glanceclient/common/http.py index 2ed7750..02ea0e0 100644 --- a/glanceclient/common/http.py +++ b/glanceclient/common/http.py @@ -5,7 +5,6 @@ OpenStack Client interface. Handles the REST calls and responses. import copy import httplib import logging -import os import urlparse @@ -48,13 +47,6 @@ class HTTPClient(object): return self.connection_class(*self.endpoint) def http_log(self, args, kwargs, resp): - if os.environ.get('GLANCECLIENT_DEBUG', False): - ch = logging.StreamHandler() - logger.setLevel(logging.DEBUG) - logger.addHandler(ch) - elif not logger.isEnabledFor(logging.DEBUG): - return - string_parts = ['curl -i'] for element in args: if element in ('GET', 'POST'): diff --git a/glanceclient/shell.py b/glanceclient/shell.py index cbc61ce..fe7a285 100644 --- a/glanceclient/shell.py +++ b/glanceclient/shell.py @@ -18,6 +18,7 @@ Command-line interface to the OpenStack Images API. """ import argparse +import logging import re import sys @@ -47,9 +48,9 @@ class OpenStackImagesShell(object): ) parser.add_argument('--debug', - default=False, + default=bool(utils.env('GLANCECLIENT_DEBUG')), action='store_true', - help=argparse.SUPPRESS) + help='Defaults to env[GLANCECLIENT_DEBUG]') parser.add_argument('--insecure', default=False, @@ -238,6 +239,10 @@ class OpenStackImagesShell(object): self.do_help(args) return 0 + LOG = logging.getLogger('glanceclient') + LOG.addHandler(logging.StreamHandler()) + LOG.setLevel(logging.DEBUG if args.debug else logging.INFO) + auth_reqd = (utils.is_authentication_required(args.func) and not (args.os_auth_token and args.os_image_url)) |
