Merge "Sync with oslo-incubator caed79d"

This commit is contained in:
Jenkins
2014-05-29 02:13:21 +00:00
committed by Gerrit Code Review
6 changed files with 15 additions and 13 deletions

View File

@@ -75,8 +75,8 @@ class HookableMixin(object):
:param cls: class that registers hooks :param cls: class that registers hooks
:param hook_type: hook type, e.g., '__pre_parse_args__' :param hook_type: hook type, e.g., '__pre_parse_args__'
:param **args: args to be passed to every hook function :param args: args to be passed to every hook function
:param **kwargs: kwargs to be passed to every hook function :param kwargs: kwargs to be passed to every hook function
""" """
hook_funcs = cls._hooks_map.get(hook_type) or [] hook_funcs = cls._hooks_map.get(hook_type) or []
for hook_func in hook_funcs: for hook_func in hook_funcs:

View File

@@ -47,6 +47,7 @@ class HTTPClient(object):
"""This client handles sending HTTP requests to OpenStack servers. """This client handles sending HTTP requests to OpenStack servers.
Features: Features:
- share authentication information between several clients to different - share authentication information between several clients to different
services (e.g., for compute and image clients); services (e.g., for compute and image clients);
- reissue authentication request for expired tokens; - reissue authentication request for expired tokens;
@@ -152,7 +153,7 @@ class HTTPClient(object):
:param method: method of HTTP request :param method: method of HTTP request
:param url: URL of HTTP request :param url: URL of HTTP request
:param kwargs: any other parameter that can be passed to :param kwargs: any other parameter that can be passed to
' requests.Session.request (such as `headers`) or `json` requests.Session.request (such as `headers`) or `json`
that will be encoded as JSON and used as `data` argument that will be encoded as JSON and used as `data` argument
""" """
kwargs.setdefault("headers", kwargs.get("headers", {})) kwargs.setdefault("headers", kwargs.get("headers", {}))
@@ -207,7 +208,7 @@ class HTTPClient(object):
:param method: method of HTTP request :param method: method of HTTP request
:param url: URL of HTTP request :param url: URL of HTTP request
:param kwargs: any other parameter that can be passed to :param kwargs: any other parameter that can be passed to
' `HTTPClient.request` `HTTPClient.request`
""" """
filter_args = { filter_args = {

View File

@@ -24,10 +24,10 @@ import traceback
def import_class(import_str): def import_class(import_str):
"""Returns a class from a string including module and class.""" """Returns a class from a string including module and class."""
mod_str, _sep, class_str = import_str.rpartition('.') mod_str, _sep, class_str = import_str.rpartition('.')
try:
__import__(mod_str) __import__(mod_str)
try:
return getattr(sys.modules[mod_str], class_str) return getattr(sys.modules[mod_str], class_str)
except (ValueError, AttributeError): except AttributeError:
raise ImportError('Class %s cannot be found (%s)' % raise ImportError('Class %s cannot be found (%s)' %
(class_str, (class_str,
traceback.format_exception(*sys.exc_info()))) traceback.format_exception(*sys.exc_info())))

View File

@@ -31,6 +31,7 @@ This module provides a few things:
''' '''
import codecs
import datetime import datetime
import functools import functools
import inspect import inspect
@@ -52,6 +53,7 @@ import six.moves.xmlrpc_client as xmlrpclib
from keystoneclient.openstack.common import gettextutils from keystoneclient.openstack.common import gettextutils
from keystoneclient.openstack.common import importutils from keystoneclient.openstack.common import importutils
from keystoneclient.openstack.common import strutils
from keystoneclient.openstack.common import timeutils from keystoneclient.openstack.common import timeutils
netaddr = importutils.try_import("netaddr") netaddr = importutils.try_import("netaddr")
@@ -166,12 +168,12 @@ def dumps(value, default=to_primitive, **kwargs):
return json.dumps(value, default=default, **kwargs) return json.dumps(value, default=default, **kwargs)
def loads(s): def loads(s, encoding='utf-8'):
return json.loads(s) return json.loads(strutils.safe_decode(s, encoding))
def load(fp): def load(fp, encoding='utf-8'):
return json.load(fp) return json.load(codecs.getreader(encoding)(fp))
try: try:

View File

@@ -22,7 +22,6 @@ from keystoneclient.openstack.common import timeutils
memcache_opts = [ memcache_opts = [
cfg.ListOpt('memcached_servers', cfg.ListOpt('memcached_servers',
default=None,
help='Memcached servers or None for in process cache.'), help='Memcached servers or None for in process cache.'),
] ]