Skip to content

Commit

Permalink
Replace ujson with json
Browse files Browse the repository at this point in the history
ujson has not had any active maintenance for the last 12 months;
switch to using json module instead.

Change-Id: I39027b534e94b3f877d881647a7c843183f60f92
Closes-Bug: 1737989
  • Loading branch information
javacruft committed Jan 3, 2018
1 parent a6da5a6 commit 05050e4
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions ceilometer/publisher/gnocchi.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from collections import defaultdict
import hashlib
import itertools
import json
import operator
import pkg_resources
import threading
Expand All @@ -28,7 +29,6 @@
import six
import six.moves.urllib.parse as urlparse
from stevedore import extension
import ujson

from ceilometer import declarative
from ceilometer import gnocchi_client
Expand Down Expand Up @@ -502,7 +502,7 @@ def _delete_event(self, rd, event):
def _search_resource(self, resource_type, query):
try:
return self._gnocchi.resource.search(
resource_type, ujson.loads(query))
resource_type, json.loads(query))
except Exception:
LOG.error("Fail to search resource type %{resource_type}s "
"with '%{query}s'",
Expand Down
5 changes: 3 additions & 2 deletions ceilometer/publisher/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.

import json

from oslo_log import log
from oslo_utils import strutils
import requests
from requests import adapters
from six.moves.urllib import parse as urlparse
import ujson

from ceilometer import publisher

Expand Down Expand Up @@ -154,7 +155,7 @@ def _do_post(self, data):
if not data:
LOG.debug('Data set is empty!')
return
data = ujson.dumps(data)
data = json.dumps(data)
LOG.trace('Message: %s', data)
try:
res = self.session.post(self.target, data=data,
Expand Down
7 changes: 4 additions & 3 deletions ceilometer/tests/tempest/aodh/service/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.

import json

from six.moves.urllib import parse as urllib
from tempest import config
from tempest.lib.common import rest_client
from tempest import manager
import ujson

CONF = config.CONF

Expand All @@ -28,10 +29,10 @@ class AlarmingClient(rest_client.RestClient):
uri_prefix = "v2"

def deserialize(self, body):
return ujson.loads(body.replace("\n", ""))
return json.loads(body.replace("\n", ""))

def serialize(self, body):
return ujson.dumps(body)
return json.dumps(body)

def list_alarms(self, query=None):
uri = '%s/alarms' % self.uri_prefix
Expand Down
2 changes: 1 addition & 1 deletion ceilometer/tests/unit/publisher/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,5 +260,5 @@ def test_post_raw_only(self):
with mock.patch.object(requests.Session, 'post') as post:
publisher.publish_events(self.event_data)
self.assertEqual(
'[{"some":"aa"},{"some":"aa"},{"some":"aa"}]',
'[{"some": "aa"}, {"some": "aa"}, {"some": "aa"}]',
post.call_args[1]['data'])
7 changes: 4 additions & 3 deletions ceilometer/tests/unit/publisher/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
# under the License.
"""Tests for ceilometer/publisher/utils.py
"""
import json

from oslotest import base
import ujson

from ceilometer.publisher import utils

Expand Down Expand Up @@ -104,7 +105,7 @@ def test_verify_signature_nested_json(self):
data['message_signature'] = utils.compute_signature(
data,
'not-so-secret')
jsondata = ujson.loads(ujson.dumps(data))
jsondata = json.loads(json.dumps(data))
self.assertTrue(utils.verify_signature(jsondata, 'not-so-secret'))

def test_verify_unicode_symbols(self):
Expand All @@ -114,7 +115,7 @@ def test_verify_unicode_symbols(self):
data['message_signature'] = utils.compute_signature(
data,
'not-so-secret')
jsondata = ujson.loads(ujson.dumps(data))
jsondata = json.loads(json.dumps(data))
self.assertTrue(utils.verify_signature(jsondata, 'not-so-secret'))

def test_verify_no_secret(self):
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ oslo.reports>=0.6.0 # Apache-2.0
oslo.rootwrap>=2.0.0 # Apache-2.0
pbr>=1.6 # Apache-2.0
oslo.messaging>=5.12.0 # Apache-2.0
ujson
oslo.utils>=3.5.0 # Apache-2.0
pysnmp<5.0.0,>=4.2.3 # BSD
python-glanceclient>=2.0.0 # Apache-2.0
Expand Down

0 comments on commit 05050e4

Please sign in to comment.