Replace ujson with json
ujson has not had any active maintenance for the last 12 months; switch to using json module instead. Change-Id: I39027b534e94b3f877d881647a7c843183f60f92 Closes-Bug: 1737989
This commit is contained in:
parent
a6da5a6b2f
commit
05050e4b21
@ -15,6 +15,7 @@
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
import hashlib
|
import hashlib
|
||||||
import itertools
|
import itertools
|
||||||
|
import json
|
||||||
import operator
|
import operator
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
import threading
|
import threading
|
||||||
@ -28,7 +29,6 @@ from oslo_utils import timeutils
|
|||||||
import six
|
import six
|
||||||
import six.moves.urllib.parse as urlparse
|
import six.moves.urllib.parse as urlparse
|
||||||
from stevedore import extension
|
from stevedore import extension
|
||||||
import ujson
|
|
||||||
|
|
||||||
from ceilometer import declarative
|
from ceilometer import declarative
|
||||||
from ceilometer import gnocchi_client
|
from ceilometer import gnocchi_client
|
||||||
@ -502,7 +502,7 @@ class GnocchiPublisher(publisher.ConfigPublisherBase):
|
|||||||
def _search_resource(self, resource_type, query):
|
def _search_resource(self, resource_type, query):
|
||||||
try:
|
try:
|
||||||
return self._gnocchi.resource.search(
|
return self._gnocchi.resource.search(
|
||||||
resource_type, ujson.loads(query))
|
resource_type, json.loads(query))
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.error("Fail to search resource type %{resource_type}s "
|
LOG.error("Fail to search resource type %{resource_type}s "
|
||||||
"with '%{query}s'",
|
"with '%{query}s'",
|
||||||
|
@ -13,12 +13,13 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
import requests
|
import requests
|
||||||
from requests import adapters
|
from requests import adapters
|
||||||
from six.moves.urllib import parse as urlparse
|
from six.moves.urllib import parse as urlparse
|
||||||
import ujson
|
|
||||||
|
|
||||||
from ceilometer import publisher
|
from ceilometer import publisher
|
||||||
|
|
||||||
@ -154,7 +155,7 @@ class HttpPublisher(publisher.ConfigPublisherBase):
|
|||||||
if not data:
|
if not data:
|
||||||
LOG.debug('Data set is empty!')
|
LOG.debug('Data set is empty!')
|
||||||
return
|
return
|
||||||
data = ujson.dumps(data)
|
data = json.dumps(data)
|
||||||
LOG.trace('Message: %s', data)
|
LOG.trace('Message: %s', data)
|
||||||
try:
|
try:
|
||||||
res = self.session.post(self.target, data=data,
|
res = self.session.post(self.target, data=data,
|
||||||
|
@ -13,11 +13,12 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
from six.moves.urllib import parse as urllib
|
from six.moves.urllib import parse as urllib
|
||||||
from tempest import config
|
from tempest import config
|
||||||
from tempest.lib.common import rest_client
|
from tempest.lib.common import rest_client
|
||||||
from tempest import manager
|
from tempest import manager
|
||||||
import ujson
|
|
||||||
|
|
||||||
CONF = config.CONF
|
CONF = config.CONF
|
||||||
|
|
||||||
@ -28,10 +29,10 @@ class AlarmingClient(rest_client.RestClient):
|
|||||||
uri_prefix = "v2"
|
uri_prefix = "v2"
|
||||||
|
|
||||||
def deserialize(self, body):
|
def deserialize(self, body):
|
||||||
return ujson.loads(body.replace("\n", ""))
|
return json.loads(body.replace("\n", ""))
|
||||||
|
|
||||||
def serialize(self, body):
|
def serialize(self, body):
|
||||||
return ujson.dumps(body)
|
return json.dumps(body)
|
||||||
|
|
||||||
def list_alarms(self, query=None):
|
def list_alarms(self, query=None):
|
||||||
uri = '%s/alarms' % self.uri_prefix
|
uri = '%s/alarms' % self.uri_prefix
|
||||||
|
@ -260,5 +260,5 @@ class TestHttpPublisher(base.BaseTestCase):
|
|||||||
with mock.patch.object(requests.Session, 'post') as post:
|
with mock.patch.object(requests.Session, 'post') as post:
|
||||||
publisher.publish_events(self.event_data)
|
publisher.publish_events(self.event_data)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'[{"some":"aa"},{"some":"aa"},{"some":"aa"}]',
|
'[{"some": "aa"}, {"some": "aa"}, {"some": "aa"}]',
|
||||||
post.call_args[1]['data'])
|
post.call_args[1]['data'])
|
||||||
|
@ -14,8 +14,9 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
"""Tests for ceilometer/publisher/utils.py
|
"""Tests for ceilometer/publisher/utils.py
|
||||||
"""
|
"""
|
||||||
|
import json
|
||||||
|
|
||||||
from oslotest import base
|
from oslotest import base
|
||||||
import ujson
|
|
||||||
|
|
||||||
from ceilometer.publisher import utils
|
from ceilometer.publisher import utils
|
||||||
|
|
||||||
@ -104,7 +105,7 @@ class TestSignature(base.BaseTestCase):
|
|||||||
data['message_signature'] = utils.compute_signature(
|
data['message_signature'] = utils.compute_signature(
|
||||||
data,
|
data,
|
||||||
'not-so-secret')
|
'not-so-secret')
|
||||||
jsondata = ujson.loads(ujson.dumps(data))
|
jsondata = json.loads(json.dumps(data))
|
||||||
self.assertTrue(utils.verify_signature(jsondata, 'not-so-secret'))
|
self.assertTrue(utils.verify_signature(jsondata, 'not-so-secret'))
|
||||||
|
|
||||||
def test_verify_unicode_symbols(self):
|
def test_verify_unicode_symbols(self):
|
||||||
@ -114,7 +115,7 @@ class TestSignature(base.BaseTestCase):
|
|||||||
data['message_signature'] = utils.compute_signature(
|
data['message_signature'] = utils.compute_signature(
|
||||||
data,
|
data,
|
||||||
'not-so-secret')
|
'not-so-secret')
|
||||||
jsondata = ujson.loads(ujson.dumps(data))
|
jsondata = json.loads(json.dumps(data))
|
||||||
self.assertTrue(utils.verify_signature(jsondata, 'not-so-secret'))
|
self.assertTrue(utils.verify_signature(jsondata, 'not-so-secret'))
|
||||||
|
|
||||||
def test_verify_no_secret(self):
|
def test_verify_no_secret(self):
|
||||||
|
@ -19,7 +19,6 @@ oslo.reports>=0.6.0 # Apache-2.0
|
|||||||
oslo.rootwrap>=2.0.0 # Apache-2.0
|
oslo.rootwrap>=2.0.0 # Apache-2.0
|
||||||
pbr>=1.6 # Apache-2.0
|
pbr>=1.6 # Apache-2.0
|
||||||
oslo.messaging>=5.12.0 # Apache-2.0
|
oslo.messaging>=5.12.0 # Apache-2.0
|
||||||
ujson
|
|
||||||
oslo.utils>=3.5.0 # Apache-2.0
|
oslo.utils>=3.5.0 # Apache-2.0
|
||||||
pysnmp<5.0.0,>=4.2.3 # BSD
|
pysnmp<5.0.0,>=4.2.3 # BSD
|
||||||
python-glanceclient>=2.0.0 # Apache-2.0
|
python-glanceclient>=2.0.0 # Apache-2.0
|
||||||
|
Loading…
Reference in New Issue
Block a user