remove remaining simplejson uses, prefer standard library import
a1c32702
,736cf54a
, and38787d0f
remove uses of `simplejson` from various parts of Swift in favor of the standard libary `json` module (introduced in Python 2.6). This commit performs the remaining `simplejson` to `json` replacements, removes two comments highlighting quirks of simplejson with respect to Unicode, and removes the references to it in setup documentation and requirements.txt. There were a lot of places where we were importing json from swift.common.utils, which is less intuitive than a direct `import json`, so that replacement is made as well. (And in two more tiny drive-bys, we add some pretty-indenting to an XML fragment and use `super` rather than naming a base class explicitly.) Change-Id: I769e88dda7f76ce15cf7ce930dc1874d24f9498a
This commit is contained in:
parent
c03d53ab77
commit
1b8b08039a
@ -20,7 +20,7 @@ from hashlib import md5
|
||||
import getopt
|
||||
from itertools import chain
|
||||
|
||||
import simplejson
|
||||
import json
|
||||
from eventlet.greenpool import GreenPool
|
||||
from eventlet.event import Event
|
||||
from six.moves.urllib.parse import quote
|
||||
@ -176,7 +176,7 @@ class Auditor(object):
|
||||
break
|
||||
if node['id'] not in responses:
|
||||
responses[node['id']] = dict(resp.getheaders())
|
||||
results = simplejson.loads(resp.read())
|
||||
results = json.loads(resp.read())
|
||||
except Exception:
|
||||
self.container_exceptions += 1
|
||||
consistent = False
|
||||
@ -249,7 +249,7 @@ class Auditor(object):
|
||||
" from %ss:%ss" %
|
||||
(account, node['ip'], node['device']))
|
||||
break
|
||||
results = simplejson.loads(resp.read())
|
||||
results = json.loads(resp.read())
|
||||
except Exception:
|
||||
self.account_exceptions += 1
|
||||
consistent = False
|
||||
|
@ -14,15 +14,12 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
from collections import defaultdict
|
||||
from six.moves.configparser import ConfigParser
|
||||
from optparse import OptionParser
|
||||
from sys import exit, stdout, stderr
|
||||
from time import time
|
||||
try:
|
||||
import simplejson as json
|
||||
except ImportError:
|
||||
import json
|
||||
|
||||
from eventlet import GreenPool, hubs, patcher, Timeout
|
||||
from eventlet.pools import Pool
|
||||
|
@ -39,7 +39,7 @@ Installing dependencies
|
||||
sudo apt-get install curl gcc memcached rsync sqlite3 xfsprogs \
|
||||
git-core libffi-dev python-setuptools
|
||||
sudo apt-get install python-coverage python-dev python-nose \
|
||||
python-simplejson python-xattr python-eventlet \
|
||||
python-xattr python-eventlet \
|
||||
python-greenlet python-pastedeploy \
|
||||
python-netifaces python-pip python-dnspython \
|
||||
python-mock
|
||||
@ -50,14 +50,14 @@ Installing dependencies
|
||||
sudo yum install curl gcc memcached rsync sqlite xfsprogs git-core \
|
||||
libffi-devel xinetd python-setuptools \
|
||||
python-coverage python-devel python-nose \
|
||||
python-simplejson pyxattr python-eventlet \
|
||||
pyxattr python-eventlet \
|
||||
python-greenlet python-paste-deploy \
|
||||
python-netifaces python-pip python-dns \
|
||||
python-mock
|
||||
|
||||
Note: This installs necessary system dependencies and *most* of the python
|
||||
dependencies. Later in the process setuptools/distribute or pip will install
|
||||
and/or upgrade packages.
|
||||
and/or upgrade packages.
|
||||
|
||||
Next, choose either :ref:`partition-section` or :ref:`loopback-section`.
|
||||
|
||||
|
@ -9,7 +9,6 @@ eventlet>=0.16.1,!=0.17.0
|
||||
greenlet>=0.3.1
|
||||
netifaces>=0.5,!=0.10.0,!=0.10.1
|
||||
pastedeploy>=1.3.3
|
||||
simplejson>=2.0.9
|
||||
six>=1.9.0
|
||||
xattr>=0.4
|
||||
PyECLib==1.0.7 # BSD
|
||||
|
@ -13,11 +13,12 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import time
|
||||
from xml.sax import saxutils
|
||||
|
||||
from swift.common.swob import HTTPOk, HTTPNoContent
|
||||
from swift.common.utils import json, Timestamp
|
||||
from swift.common.utils import Timestamp
|
||||
from swift.common.storage_policy import POLICIES
|
||||
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
from contextlib import contextmanager, closing
|
||||
import hashlib
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
from uuid import uuid4
|
||||
@ -32,7 +33,7 @@ from eventlet import sleep, Timeout
|
||||
import sqlite3
|
||||
|
||||
from swift.common.constraints import MAX_META_COUNT, MAX_META_OVERALL_SIZE
|
||||
from swift.common.utils import json, Timestamp, renamer, \
|
||||
from swift.common.utils import Timestamp, renamer, \
|
||||
mkdirs, lock_parent_directory, fallocate
|
||||
from swift.common.exceptions import LockTimeout
|
||||
from swift.common.swob import HTTPBadRequest
|
||||
|
@ -18,6 +18,7 @@ Internal client library for making calls directly to the servers rather than
|
||||
through the proxy.
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import socket
|
||||
from time import time
|
||||
@ -34,11 +35,6 @@ from swift.common.http import HTTP_NO_CONTENT, HTTP_INSUFFICIENT_STORAGE, \
|
||||
from swift.common.swob import HeaderKeyDict
|
||||
from swift.common.utils import quote
|
||||
|
||||
try:
|
||||
import simplejson as json
|
||||
except ImportError:
|
||||
import json
|
||||
|
||||
|
||||
class DirectClientException(ClientException):
|
||||
|
||||
|
@ -45,6 +45,7 @@ http://github.com/memcached/memcached/blob/1.4.2/doc/protocol.txt
|
||||
"""
|
||||
|
||||
import six.moves.cPickle as pickle
|
||||
import json
|
||||
import logging
|
||||
import time
|
||||
from bisect import bisect
|
||||
@ -56,7 +57,6 @@ from eventlet.pools import Pool
|
||||
from eventlet import Timeout
|
||||
from six.moves import range
|
||||
|
||||
from swift.common.utils import json
|
||||
|
||||
DEFAULT_MEMCACHED_PORT = 11211
|
||||
|
||||
|
@ -13,7 +13,9 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from swift.common.utils import urlparse, json
|
||||
import json
|
||||
|
||||
from swift.common.utils import urlparse
|
||||
|
||||
|
||||
def clean_acl(name, value):
|
||||
|
@ -13,6 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
from six.moves.urllib.parse import quote, unquote
|
||||
import tarfile
|
||||
from xml.sax import saxutils
|
||||
@ -23,7 +24,7 @@ from swift.common.swob import Request, HTTPBadGateway, \
|
||||
HTTPCreated, HTTPBadRequest, HTTPNotFound, HTTPUnauthorized, HTTPOk, \
|
||||
HTTPPreconditionFailed, HTTPRequestEntityTooLarge, HTTPNotAcceptable, \
|
||||
HTTPLengthRequired, HTTPException, HTTPServerError, wsgify
|
||||
from swift.common.utils import json, get_logger, register_swift_info
|
||||
from swift.common.utils import get_logger, register_swift_info
|
||||
from swift.common import constraints
|
||||
from swift.common.http import HTTP_UNAUTHORIZED, HTTP_NOT_FOUND, HTTP_CONFLICT
|
||||
|
||||
@ -32,7 +33,7 @@ class CreateContainerError(Exception):
|
||||
def __init__(self, msg, status_int, status):
|
||||
self.status_int = status_int
|
||||
self.status = status
|
||||
Exception.__init__(self, msg)
|
||||
super(CreateContainerError, self).__init__(msg)
|
||||
|
||||
|
||||
ACCEPTABLE_FORMATS = ['text/plain', 'application/json', 'application/xml',
|
||||
|
@ -114,6 +114,7 @@ Here's an example using ``curl`` with tiny 1-byte segments::
|
||||
http://<storage_url>/container/myobject
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
import six
|
||||
@ -126,7 +127,7 @@ from swift.common.exceptions import ListingIterError, SegmentError
|
||||
from swift.common.http import is_success
|
||||
from swift.common.swob import Request, Response, \
|
||||
HTTPRequestedRangeNotSatisfiable, HTTPBadRequest, HTTPConflict
|
||||
from swift.common.utils import get_logger, json, \
|
||||
from swift.common.utils import get_logger, \
|
||||
RateLimitedIterator, read_conf_dir, quote, close_if_possible, \
|
||||
closing_if_possible
|
||||
from swift.common.request_helpers import SegmentedIterable
|
||||
|
@ -78,11 +78,12 @@ with this middleware enabled should not be open to an untrusted
|
||||
environment (everyone can query the locality data using this middleware).
|
||||
"""
|
||||
|
||||
import json
|
||||
|
||||
from six.moves.urllib.parse import quote, unquote
|
||||
|
||||
from swift.common.ring import Ring
|
||||
from swift.common.utils import json, get_logger, split_path
|
||||
from swift.common.utils import get_logger, split_path
|
||||
from swift.common.swob import Request, Response
|
||||
from swift.common.swob import HTTPBadRequest, HTTPMethodNotAllowed
|
||||
from swift.common.storage_policy import POLICIES
|
||||
|
@ -14,6 +14,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import errno
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
from swift import gettext_ as _
|
||||
@ -21,7 +22,7 @@ from swift import gettext_ as _
|
||||
from swift import __version__ as swiftver
|
||||
from swift.common.storage_policy import POLICIES
|
||||
from swift.common.swob import Request, Response
|
||||
from swift.common.utils import get_logger, config_true_value, json, \
|
||||
from swift.common.utils import get_logger, config_true_value, \
|
||||
SWIFT_CONF_FILE
|
||||
from swift.common.constraints import check_mount
|
||||
from resource import getpagesize
|
||||
|
@ -197,6 +197,7 @@ metadata which can be used for stats purposes.
|
||||
from six.moves import range
|
||||
|
||||
from datetime import datetime
|
||||
import json
|
||||
import mimetypes
|
||||
import re
|
||||
import six
|
||||
@ -208,7 +209,7 @@ from swift.common.swob import Request, HTTPBadRequest, HTTPServerError, \
|
||||
HTTPOk, HTTPPreconditionFailed, HTTPException, HTTPNotFound, \
|
||||
HTTPUnauthorized, HTTPConflict, HTTPRequestedRangeNotSatisfiable,\
|
||||
Response, Range
|
||||
from swift.common.utils import json, get_logger, config_true_value, \
|
||||
from swift.common.utils import get_logger, config_true_value, \
|
||||
get_valid_utf8_str, override_bytes_from_content_type, split_path, \
|
||||
register_swift_info, RateLimitedIterator, quote, close_if_possible, \
|
||||
closing_if_possible
|
||||
|
@ -113,10 +113,11 @@ Disable versioning from a container (x is any value except empty)::
|
||||
-H "X-Remove-Versions-Location: x" http://<storage_url>/container
|
||||
"""
|
||||
|
||||
import json
|
||||
import six
|
||||
from six.moves.urllib.parse import quote, unquote
|
||||
import time
|
||||
from swift.common.utils import get_logger, Timestamp, json, \
|
||||
from swift.common.utils import get_logger, Timestamp, \
|
||||
register_swift_info, config_true_value
|
||||
from swift.common.request_helpers import get_sys_meta_prefix
|
||||
from swift.common.wsgi import WSGIContext, make_pre_authed_request
|
||||
|
@ -16,6 +16,7 @@
|
||||
import array
|
||||
import six.moves.cPickle as pickle
|
||||
import inspect
|
||||
import json
|
||||
from collections import defaultdict
|
||||
from gzip import GzipFile
|
||||
from os.path import getmtime
|
||||
@ -29,7 +30,7 @@ from tempfile import NamedTemporaryFile
|
||||
|
||||
from six.moves import range
|
||||
|
||||
from swift.common.utils import hash_path, validate_configuration, json
|
||||
from swift.common.utils import hash_path, validate_configuration
|
||||
from swift.common.ring.utils import tiers_for_dev
|
||||
|
||||
|
||||
|
@ -21,6 +21,7 @@ import errno
|
||||
import fcntl
|
||||
import grp
|
||||
import hmac
|
||||
import json
|
||||
import operator
|
||||
import os
|
||||
import pwd
|
||||
@ -39,10 +40,6 @@ import ctypes.util
|
||||
from optparse import OptionParser
|
||||
|
||||
from tempfile import mkstemp, NamedTemporaryFile
|
||||
try:
|
||||
import simplejson as json
|
||||
except ImportError:
|
||||
import json
|
||||
import glob
|
||||
import itertools
|
||||
import stat
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
import os
|
||||
import itertools
|
||||
import json
|
||||
import time
|
||||
from collections import defaultdict
|
||||
from eventlet import Timeout
|
||||
@ -28,7 +29,7 @@ from swift.common.storage_policy import POLICIES
|
||||
from swift.common.exceptions import DeviceUnavailable
|
||||
from swift.common.http import is_success
|
||||
from swift.common.db import DatabaseAlreadyExists
|
||||
from swift.common.utils import (json, Timestamp, hash_path,
|
||||
from swift.common.utils import (Timestamp, hash_path,
|
||||
storage_directory, quorum_size)
|
||||
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
import traceback
|
||||
@ -30,7 +31,7 @@ from swift.common.request_helpers import get_param, get_listing_content_type, \
|
||||
split_and_validate_path, is_sys_or_user_meta
|
||||
from swift.common.utils import get_logger, hash_path, public, \
|
||||
Timestamp, storage_directory, validate_sync_to, \
|
||||
config_true_value, json, timing_stats, replication, \
|
||||
config_true_value, timing_stats, replication, \
|
||||
override_bytes_from_content_type, get_log_line
|
||||
from swift.common.constraints import check_mount, valid_timestamp, check_utf8
|
||||
from swift.common import constraints
|
||||
|
@ -13,6 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
@ -24,7 +25,7 @@ from eventlet import Timeout
|
||||
|
||||
from swift.obj import diskfile
|
||||
from swift.common.utils import get_logger, ratelimit_sleep, dump_recon_cache, \
|
||||
list_from_csv, json, listdir
|
||||
list_from_csv, listdir
|
||||
from swift.common.exceptions import DiskFileQuarantined, DiskFileNotExist
|
||||
from swift.common.daemon import Daemon
|
||||
|
||||
|
@ -13,9 +13,10 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
from time import time
|
||||
|
||||
from swift.common.utils import public, get_hmac, get_swift_info, json, \
|
||||
from swift.common.utils import public, get_hmac, get_swift_info, \
|
||||
streq_const_time
|
||||
from swift.proxy.controllers.base import Controller, delay_denial
|
||||
from swift.common.swob import HTTPOk, HTTPForbidden, HTTPUnauthorized
|
||||
|
@ -29,6 +29,7 @@ from six.moves.urllib.parse import unquote, quote
|
||||
|
||||
import collections
|
||||
import itertools
|
||||
import json
|
||||
import mimetypes
|
||||
import time
|
||||
import math
|
||||
@ -43,7 +44,7 @@ from eventlet.timeout import Timeout
|
||||
|
||||
from swift.common.utils import (
|
||||
clean_content_type, config_true_value, ContextPool, csv_append,
|
||||
GreenAsyncPile, GreenthreadSafeIterator, json, Timestamp,
|
||||
GreenAsyncPile, GreenthreadSafeIterator, Timestamp,
|
||||
normalize_delete_at_timestamp, public, get_expirer_container,
|
||||
document_iters_to_http_response_body, parse_content_range,
|
||||
quorum_size, reiterate, close_if_possible)
|
||||
|
@ -14,12 +14,12 @@
|
||||
# limitations under the License.
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
import socket
|
||||
import time
|
||||
|
||||
import simplejson as json
|
||||
from nose import SkipTest
|
||||
from xml.dom import minidom
|
||||
|
||||
|
@ -24,7 +24,7 @@ from test.unit import FakeLogger
|
||||
import itertools
|
||||
import random
|
||||
|
||||
import simplejson
|
||||
import json
|
||||
from six import BytesIO
|
||||
from six import StringIO
|
||||
import xml.dom.minidom
|
||||
@ -806,7 +806,7 @@ class TestAccountController(unittest.TestCase):
|
||||
environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
self.assertEqual(simplejson.loads(resp.body),
|
||||
self.assertEqual(json.loads(resp.body),
|
||||
[{'count': 0, 'bytes': 0, 'name': 'c1'},
|
||||
{'count': 0, 'bytes': 0, 'name': 'c2'}])
|
||||
req = Request.blank('/sda1/p/a/c1', environ={'REQUEST_METHOD': 'PUT'},
|
||||
@ -827,7 +827,7 @@ class TestAccountController(unittest.TestCase):
|
||||
environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
self.assertEqual(simplejson.loads(resp.body),
|
||||
self.assertEqual(json.loads(resp.body),
|
||||
[{'count': 1, 'bytes': 2, 'name': 'c1'},
|
||||
{'count': 3, 'bytes': 4, 'name': 'c2'}])
|
||||
self.assertEqual(resp.content_type, 'application/json')
|
||||
@ -1031,7 +1031,7 @@ class TestAccountController(unittest.TestCase):
|
||||
environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
self.assertEqual(simplejson.loads(resp.body),
|
||||
self.assertEqual(json.loads(resp.body),
|
||||
[{'count': 2, 'bytes': 3, 'name': 'c0'},
|
||||
{'count': 2, 'bytes': 3, 'name': 'c1'},
|
||||
{'count': 2, 'bytes': 3, 'name': 'c2'}])
|
||||
@ -1039,7 +1039,7 @@ class TestAccountController(unittest.TestCase):
|
||||
environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
self.assertEqual(simplejson.loads(resp.body),
|
||||
self.assertEqual(json.loads(resp.body),
|
||||
[{'count': 2, 'bytes': 3, 'name': 'c3'},
|
||||
{'count': 2, 'bytes': 3, 'name': 'c4'}])
|
||||
|
||||
@ -1152,7 +1152,7 @@ class TestAccountController(unittest.TestCase):
|
||||
req.accept = 'application/*'
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
self.assertEqual(len(simplejson.loads(resp.body)), 1)
|
||||
self.assertEqual(len(json.loads(resp.body)), 1)
|
||||
|
||||
def test_GET_accept_json(self):
|
||||
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'PUT',
|
||||
@ -1169,7 +1169,7 @@ class TestAccountController(unittest.TestCase):
|
||||
req.accept = 'application/json'
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
self.assertEqual(len(simplejson.loads(resp.body)), 1)
|
||||
self.assertEqual(len(json.loads(resp.body)), 1)
|
||||
|
||||
def test_GET_accept_xml(self):
|
||||
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'PUT',
|
||||
@ -1305,14 +1305,14 @@ class TestAccountController(unittest.TestCase):
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
self.assertEqual([n.get('name', 's:' + n.get('subdir', 'error'))
|
||||
for n in simplejson.loads(resp.body)], ['s:sub.'])
|
||||
for n in json.loads(resp.body)], ['s:sub.'])
|
||||
req = Request.blank('/sda1/p/a?prefix=sub.&delimiter=.&format=json',
|
||||
environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
self.assertEqual(
|
||||
[n.get('name', 's:' + n.get('subdir', 'error'))
|
||||
for n in simplejson.loads(resp.body)],
|
||||
for n in json.loads(resp.body)],
|
||||
['sub.0', 's:sub.0.', 'sub.1', 's:sub.1.', 'sub.2', 's:sub.2.'])
|
||||
req = Request.blank('/sda1/p/a?prefix=sub.1.&delimiter=.&format=json',
|
||||
environ={'REQUEST_METHOD': 'GET'})
|
||||
@ -1320,7 +1320,7 @@ class TestAccountController(unittest.TestCase):
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
self.assertEqual(
|
||||
[n.get('name', 's:' + n.get('subdir', 'error'))
|
||||
for n in simplejson.loads(resp.body)],
|
||||
for n in json.loads(resp.body)],
|
||||
['sub.1.0', 'sub.1.1', 'sub.1.2'])
|
||||
|
||||
def test_GET_prefix_delimiter_xml(self):
|
||||
|
@ -17,6 +17,7 @@
|
||||
from six.moves import range
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import time
|
||||
import unittest
|
||||
from mock import patch
|
||||
@ -25,17 +26,17 @@ from swift.common import swob, utils
|
||||
from swift.common.exceptions import ListingIterError, SegmentError
|
||||
from swift.common.middleware import slo
|
||||
from swift.common.swob import Request, Response, HTTPException
|
||||
from swift.common.utils import quote, json, closing_if_possible
|
||||
from swift.common.utils import quote, closing_if_possible
|
||||
from test.unit.common.middleware.helpers import FakeSwift
|
||||
|
||||
|
||||
test_xml_data = '''<?xml version="1.0" encoding="UTF-8"?>
|
||||
<static_large_object>
|
||||
<object_segment>
|
||||
<path>/cont/object</path>
|
||||
<etag>etagoftheobjectsegment</etag>
|
||||
<size_bytes>100</size_bytes>
|
||||
</object_segment>
|
||||
<object_segment>
|
||||
<path>/cont/object</path>
|
||||
<etag>etagoftheobjectsegment</etag>
|
||||
<size_bytes>100</size_bytes>
|
||||
</object_segment>
|
||||
</static_large_object>
|
||||
'''
|
||||
test_json_data = json.dumps([{'path': '/cont/object',
|
||||
|
@ -111,11 +111,6 @@ class TestBufferedHTTP(unittest.TestCase):
|
||||
bufferedhttp.HTTPSConnection = origHTTPSConnection
|
||||
|
||||
def test_unicode_values(self):
|
||||
# simplejson may decode the ring devices as str or unicode
|
||||
# depending on whether speedups is installed and/or the values are
|
||||
# non-ascii. Verify all types are tolerated in combination with
|
||||
# whatever type path might be and possible encoded non-ascii in
|
||||
# a header value.
|
||||
with mock.patch('swift.common.bufferedhttp.HTTPSConnection',
|
||||
MockHTTPSConnection):
|
||||
for dev in ('sda', u'sda', u'sdá', u'sdá'.encode('utf-8')):
|
||||
|
@ -23,7 +23,7 @@ from shutil import rmtree, copy
|
||||
from uuid import uuid4
|
||||
import six.moves.cPickle as pickle
|
||||
|
||||
import simplejson
|
||||
import json
|
||||
import sqlite3
|
||||
import itertools
|
||||
import time
|
||||
@ -39,7 +39,7 @@ from swift.common.constraints import \
|
||||
from swift.common.db import chexor, dict_factory, get_db_connection, \
|
||||
DatabaseBroker, DatabaseConnectionError, DatabaseAlreadyExists, \
|
||||
GreenDBConnection, PICKLE_PROTOCOL
|
||||
from swift.common.utils import normalize_timestamp, mkdirs, json, Timestamp
|
||||
from swift.common.utils import normalize_timestamp, mkdirs, Timestamp
|
||||
from swift.common.exceptions import LockTimeout
|
||||
from swift.common.swob import HTTPException
|
||||
|
||||
@ -963,7 +963,7 @@ class TestDatabaseBroker(unittest.TestCase):
|
||||
broker.db_contains_type = 'test'
|
||||
broker_creation = normalize_timestamp(1)
|
||||
broker_uuid = str(uuid4())
|
||||
broker_metadata = metadata and simplejson.dumps(
|
||||
broker_metadata = metadata and json.dumps(
|
||||
{'Test': ('Value', normalize_timestamp(1))}) or ''
|
||||
|
||||
def _initialize(conn, put_timestamp, **kwargs):
|
||||
|
@ -25,7 +25,7 @@ from mock import patch, call
|
||||
from shutil import rmtree, copy
|
||||
from tempfile import mkdtemp, NamedTemporaryFile
|
||||
import mock
|
||||
import simplejson
|
||||
import json
|
||||
|
||||
from swift.container.backend import DATADIR
|
||||
from swift.common import db_replicator
|
||||
@ -1207,7 +1207,7 @@ class TestReplToNode(unittest.TestCase):
|
||||
|
||||
def test_repl_to_node_usync_success(self):
|
||||
rinfo = {"id": 3, "point": -1, "max_row": 10, "hash": "c"}
|
||||
self.http = ReplHttp(simplejson.dumps(rinfo))
|
||||
self.http = ReplHttp(json.dumps(rinfo))
|
||||
local_sync = self.broker.get_sync()
|
||||
self.assertEqual(self.replicator._repl_to_node(
|
||||
self.fake_node, self.broker, '0', self.fake_info), True)
|
||||
@ -1218,7 +1218,7 @@ class TestReplToNode(unittest.TestCase):
|
||||
|
||||
def test_repl_to_node_rsync_success(self):
|
||||
rinfo = {"id": 3, "point": -1, "max_row": 9, "hash": "c"}
|
||||
self.http = ReplHttp(simplejson.dumps(rinfo))
|
||||
self.http = ReplHttp(json.dumps(rinfo))
|
||||
self.broker.get_sync()
|
||||
self.assertEqual(self.replicator._repl_to_node(
|
||||
self.fake_node, self.broker, '0', self.fake_info), True)
|
||||
@ -1235,7 +1235,7 @@ class TestReplToNode(unittest.TestCase):
|
||||
|
||||
def test_repl_to_node_already_in_sync(self):
|
||||
rinfo = {"id": 3, "point": -1, "max_row": 20, "hash": "b"}
|
||||
self.http = ReplHttp(simplejson.dumps(rinfo))
|
||||
self.http = ReplHttp(json.dumps(rinfo))
|
||||
self.broker.get_sync()
|
||||
self.assertEqual(self.replicator._repl_to_node(
|
||||
self.fake_node, self.broker, '0', self.fake_info), True)
|
||||
@ -1282,7 +1282,7 @@ class TestReplToNode(unittest.TestCase):
|
||||
rinfo['max_row'] = r
|
||||
self.fake_info['max_row'] = l
|
||||
self.replicator._usync_db = mock.Mock(return_value=True)
|
||||
self.http = ReplHttp(simplejson.dumps(rinfo))
|
||||
self.http = ReplHttp(json.dumps(rinfo))
|
||||
local_sync = self.broker.get_sync()
|
||||
self.assertEqual(self.replicator._repl_to_node(
|
||||
self.fake_node, self.broker, '0', self.fake_info), True)
|
||||
|
@ -28,7 +28,7 @@ import time
|
||||
import random
|
||||
|
||||
from eventlet import spawn, Timeout, listen
|
||||
import simplejson
|
||||
import json
|
||||
import six
|
||||
from six import BytesIO
|
||||
from six import StringIO
|
||||
@ -40,8 +40,7 @@ import swift.container
|
||||
from swift.container import server as container_server
|
||||
from swift.common import constraints
|
||||
from swift.common.utils import (Timestamp, mkdirs, public, replication,
|
||||
storage_directory, lock_parent_directory,
|
||||
json)
|
||||
storage_directory, lock_parent_directory)
|
||||
from test.unit import fake_http_connect, debug_logger
|
||||
from swift.common.storage_policy import (POLICIES, StoragePolicy)
|
||||
from swift.common.request_helpers import get_sys_meta_prefix
|
||||
@ -1691,7 +1690,7 @@ class TestContainerController(unittest.TestCase):
|
||||
environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
self.assertEqual(simplejson.loads(resp.body), [])
|
||||
self.assertEqual(json.loads(resp.body), [])
|
||||
# fill the container
|
||||
for i in range(3):
|
||||
req = Request.blank(
|
||||
@ -1726,7 +1725,7 @@ class TestContainerController(unittest.TestCase):
|
||||
environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.content_type, 'application/json')
|
||||
self.assertEqual(simplejson.loads(resp.body), json_body)
|
||||
self.assertEqual(json.loads(resp.body), json_body)
|
||||
self.assertEqual(resp.charset, 'utf-8')
|
||||
|
||||
req = Request.blank(
|
||||
@ -1743,7 +1742,7 @@ class TestContainerController(unittest.TestCase):
|
||||
req.accept = accept
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(
|
||||
simplejson.loads(resp.body), json_body,
|
||||
json.loads(resp.body), json_body,
|
||||
'Invalid body for Accept: %s' % accept)
|
||||
self.assertEqual(
|
||||
resp.content_type, 'application/json',
|
||||
@ -1873,7 +1872,7 @@ class TestContainerController(unittest.TestCase):
|
||||
environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.content_type, 'application/json')
|
||||
self.assertEqual(simplejson.loads(resp.body), json_body)
|
||||
self.assertEqual(json.loads(resp.body), json_body)
|
||||
self.assertEqual(resp.charset, 'utf-8')
|
||||
|
||||
def test_GET_xml(self):
|
||||
@ -2001,7 +2000,7 @@ class TestContainerController(unittest.TestCase):
|
||||
req = Request.blank('/sda1/p/a/c?format=json',
|
||||
environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = req.get_response(self.controller)
|
||||
result = [x['content_type'] for x in simplejson.loads(resp.body)]
|
||||
result = [x['content_type'] for x in json.loads(resp.body)]
|
||||
self.assertEqual(result, [u'\u2603', 'text/plain;charset="utf-8"'])
|
||||
|
||||
def test_GET_accept_not_valid(self):
|
||||
@ -2089,7 +2088,7 @@ class TestContainerController(unittest.TestCase):
|
||||
environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(
|
||||
simplejson.loads(resp.body),
|
||||
json.loads(resp.body),
|
||||
[{"subdir": "US-OK-"},
|
||||
{"subdir": "US-TX-"},
|
||||
{"subdir": "US-UT-"}])
|
||||
@ -2170,7 +2169,7 @@ class TestContainerController(unittest.TestCase):
|
||||
environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(
|
||||
simplejson.loads(resp.body),
|
||||
json.loads(resp.body),
|
||||
[{"name": "US/OK", "hash": "x", "bytes": 0,
|
||||
"content_type": "text/plain",
|
||||
"last_modified": "1970-01-01T00:00:01.000000"},
|
||||
|
@ -342,7 +342,6 @@ class TestFuncs(unittest.TestCase):
|
||||
def test_get_container_info_cache(self):
|
||||
cache_stub = {
|
||||
'status': 404, 'bytes': 3333, 'object_count': 10,
|
||||
# simplejson sometimes hands back strings, sometimes unicodes
|
||||
'versions': u"\u1F4A9"}
|
||||
req = Request.blank("/v1/account/cont",
|
||||
environ={'swift.cache': FakeCache(cache_stub)})
|
||||
|
@ -17,6 +17,7 @@
|
||||
from __future__ import print_function
|
||||
import email.parser
|
||||
import logging
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
import pickle
|
||||
@ -47,7 +48,7 @@ from six import StringIO
|
||||
from six.moves import range
|
||||
from six.moves.urllib.parse import quote
|
||||
|
||||
from swift.common.utils import hash_path, json, storage_directory, \
|
||||
from swift.common.utils import hash_path, storage_directory, \
|
||||
parse_content_type, parse_mime_headers, \
|
||||
iter_multipart_mime_documents, public
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user