Skip to content

Commit

Permalink
Fix --debug CLI option
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bcwaldon committed Jul 30, 2012
1 parent 1e744f1 commit 158f7cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
8 changes: 0 additions & 8 deletions glanceclient/common/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import copy
import httplib
import logging
import os
import urlparse


Expand Down Expand Up @@ -48,13 +47,6 @@ def get_connection(self):
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'):
Expand Down
9 changes: 7 additions & 2 deletions glanceclient/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""

import argparse
import logging
import re
import sys

Expand Down Expand Up @@ -47,9 +48,9 @@ def get_base_parser(self):
)

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,
Expand Down Expand Up @@ -238,6 +239,10 @@ def main(self, argv):
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))

Expand Down

0 comments on commit 158f7cc

Please sign in to comment.