Merge "Using jsonutils instead of json"

This commit is contained in:
Jenkins 2017-02-03 08:47:00 +00:00 committed by Gerrit Code Review
commit 1f7df3d53d
5 changed files with 17 additions and 17 deletions

@ -17,7 +17,6 @@ import copy
from distutils import version
import functools
import hashlib
import json
import logging
import os
import socket
@ -27,6 +26,7 @@ import time
from keystoneauth1 import adapter
from keystoneauth1 import exceptions as kexceptions
from oslo_serialization import jsonutils
from oslo_utils import strutils
import requests
import six
@ -70,10 +70,10 @@ def _extract_error_json(body):
"""Return error_message from the HTTP response body."""
error_json = {}
try:
body_json = json.loads(body)
body_json = jsonutils.loads(body)
if 'error_message' in body_json:
raw_msg = body_json['error_message']
error_json = json.loads(raw_msg)
error_json = jsonutils.loads(raw_msg)
except ValueError:
pass
@ -382,7 +382,7 @@ class HTTPClient(VersionNegotiationMixin):
kwargs['headers'].setdefault('Accept', 'application/json')
if 'body' in kwargs:
kwargs['body'] = json.dumps(kwargs['body'])
kwargs['body'] = jsonutils.dumps(kwargs['body'])
resp, body_iter = self._http_request(url, method, **kwargs)
content_type = resp.headers.get('Content-Type')
@ -395,7 +395,7 @@ class HTTPClient(VersionNegotiationMixin):
if 'application/json' in content_type:
body = ''.join([chunk for chunk in body_iter])
try:
body = json.loads(body)
body = jsonutils.loads(body)
except ValueError:
LOG.error(_LE('Could not decode response body as JSON'))
else:
@ -545,7 +545,7 @@ class SessionClient(VersionNegotiationMixin, adapter.LegacyJsonAdapter):
kwargs['headers'].setdefault('Accept', 'application/json')
if 'body' in kwargs:
kwargs['data'] = json.dumps(kwargs.pop('body'))
kwargs['data'] = jsonutils.dumps(kwargs.pop('body'))
resp = self._http_request(url, method, **kwargs)
body = resp.content

@ -17,11 +17,11 @@
from __future__ import print_function
import argparse
import json
import os
import uuid
import yaml
from oslo_serialization import jsonutils
from oslo_utils import importutils
from watcherclient._i18n import _
@ -89,7 +89,7 @@ def split_and_deserialize(string):
raise exc.CommandError(_('Attributes must be a list of '
'PATH=VALUE not "%s"') % string)
try:
value = json.loads(value)
value = jsonutils.loads(value)
except ValueError:
pass

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import json
from oslo_serialization import jsonutils
from oslo_utils import uuidutils
from keystoneauth1.fixture import v2 as ks_v2_fixture
@ -53,11 +53,11 @@ TOKENID = uuidutils.generate_uuid(dashed=False)
def _create_version_list(versions):
return json.dumps({'versions': {'values': versions}})
return jsonutils.dumps({'versions': {'values': versions}})
def _create_single_version(version):
return json.dumps({'version': version})
return jsonutils.dumps({'version': version})
V3_VERSION_LIST = _create_version_list([V3_VERSION, V2_VERSION])
@ -74,8 +74,8 @@ def keystone_request_callback(request, uri, headers):
return (200, headers, V3_VERSION_LIST)
elif uri == BASE_URL + "/v2.0":
v2_token = ks_v2_fixture.Token(token_id)
return (200, response_headers, json.dumps(v2_token))
return (200, response_headers, jsonutils.dumps(v2_token))
elif uri == BASE_URL + "/v3":
v3_token = ks_v3_fixture.Token()
response_headers["X-Subject-Token"] = token_id
return (201, response_headers, json.dumps(v3_token))
return (201, response_headers, jsonutils.dumps(v3_token))

@ -13,11 +13,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import json
import shlex
import mock
from osc_lib import utils as oscutils
from oslo_serialization import jsonutils
from watcherclient.common import httpclient
from watcherclient.tests.unit import utils
@ -55,7 +55,7 @@ class CommandTestCase(utils.BaseTestCase):
def run_cmd(self, cmd, formatting='json'):
if formatting:
formatter_arg = " -f %s" % formatting
formatter = json.loads
formatter = jsonutils.loads
else:
formatter_arg = ''
formatter = str

@ -13,8 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import json
from osc_lib import utils
from oslo_serialization import jsonutils
from watcherclient._i18n import _
from watcherclient.common import command
@ -38,7 +38,7 @@ class ShowStrategy(command.ShowOne):
def _format_spec(self, strategy):
parameters_spec = strategy.parameters_spec.get('properties')
if parameters_spec:
return json.dumps(parameters_spec, indent=2)
return jsonutils.dumps(parameters_spec, indent=2)
return {}