Sfoglia il codice sorgente

HUE-2436 [all] Django-1.6: Django deprecated use of simplejson

Erick Tryzelaar 11 anni fa
parent
commit
a77b3d0

+ 0 - 3
README.rst

@@ -83,7 +83,6 @@ your system:
       * mvn (from ``maven`` package or maven3 tarball)
       * openldap-dev / libldap2-dev
       * python-dev
-      * python-simplejson
       * python-setuptools
 
     CentOS/RHEL:
@@ -102,7 +101,6 @@ your system:
       * mysql-devel
       * openldap-devel
       * python-devel
-      * python-simplejson
       * sqlite-devel
       * openssl-devel (for version 7+)
 
@@ -111,7 +109,6 @@ your system:
       * libxml2
       * libxslt
       * mysql5-devel
-      * simplejson (easy_install)
       * sqlite3
 
 

+ 1 - 4
apps/about/src/about/tests.py

@@ -15,10 +15,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-try:
-  import json
-except ImportError:
-  import simplejson as json
+import json
 
 from django.contrib.auth.models import User
 from django.core.urlresolvers import reverse

+ 4 - 4
apps/beeswax/src/beeswax/management/commands/beeswax_install_examples.py

@@ -18,7 +18,7 @@
 import logging
 import os
 import pwd
-import simplejson
+import json
 
 from django.core.management.base import BaseCommand
 from django.contrib.auth.models import User
@@ -85,7 +85,7 @@ class Command(BaseCommand):
   def _install_tables(self, django_user, app_name):
     data_dir = beeswax.conf.LOCAL_EXAMPLES_DATA_DIR.get()
     table_file = file(os.path.join(data_dir, 'tables.json'))
-    table_list = simplejson.load(table_file)
+    table_list = json.load(table_file)
     table_file.close()
 
     for table_dict in table_list:
@@ -97,7 +97,7 @@ class Command(BaseCommand):
 
   def _install_queries(self, django_user, app_name):
     design_file = file(os.path.join(beeswax.conf.LOCAL_EXAMPLES_DATA_DIR.get(), 'designs.json'))
-    design_list = simplejson.load(design_file)
+    design_list = json.load(design_file)
     design_file.close()
 
     for design_dict in design_list:
@@ -226,7 +226,7 @@ class SampleDesign(object):
       model.type = self.type
       # The data field needs to be a string. The sample file writes it
       # as json (without encoding into a string) for readability.
-      model.data = simplejson.dumps(self.data)
+      model.data = json.dumps(self.data)
       model.desc = self.desc
       model.save()
       LOG.info('Successfully installed sample design: %s' % (self.name,))

+ 1 - 3
apps/filebrowser/src/filebrowser/views_test.py

@@ -731,9 +731,7 @@ def test_view_avro():
 
     # autodetect
     response = c.get('/filebrowser/view/test-avro-filebrowser/test-view.avro')
-    # (Note: we use eval here cause of an incompatibility issue between
-    # the representation string of JSON dicts in simplejson vs. json)
-    assert_equal(eval(response.context['view']['contents']), dummy_datum)
+    assert_equal(json.loads(response.context['view']['contents']), dummy_datum)
 
     # offsetting should work as well
     response = c.get('/filebrowser/view/test-avro-filebrowser/test-view.avro?offset=1')

+ 1 - 4
apps/jobsub/src/jobsub/migrations/0002_auto__add_ooziestreamingaction__add_oozieaction__add_oozieworkflow__ad.py

@@ -18,10 +18,7 @@
 
 import datetime
 import logging
-try:
-  import json
-except ImportError:
-  import simplejson as json
+import json
 
 from south.db import db
 from south.v2 import SchemaMigration

+ 2 - 5
apps/jobsub/src/jobsub/migrations/0004_hue1_to_hue2.py

@@ -18,10 +18,7 @@
 
 import datetime
 import logging
-try:
-  import json
-except ImportError:
-  import simplejson as json
+import json
 
 from south.db import db
 from south.v2 import DataMigration
@@ -233,4 +230,4 @@ def job_design_migration_for_streaming(jd):
                        name=jd.name,
                        description=jd.description,
                        root_action=action)
-  design.save()
+  design.save()

+ 1 - 4
apps/oozie/src/oozie/migrations/0022_change_examples_path_format.py

@@ -1,9 +1,6 @@
 # encoding: utf-8
 import datetime
-try:
-  import json
-except ImportError:
-  import simplejson as json
+import json
 from south.db import db
 from south.v2 import DataMigration
 from django.db import models

+ 1 - 4
apps/sqoop/src/sqoop/api/connector.py

@@ -15,10 +15,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-try:
-  import json
-except ImportError:
-  import simplejson as json
+import json
 import logging
 import socket
 

+ 1 - 4
apps/sqoop/src/sqoop/api/decorators.py

@@ -15,10 +15,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-try:
-  import json
-except ImportError:
-  import simplejson as json
+import json
 import logging
 
 from django.utils.translation import ugettext as _

+ 1 - 4
apps/sqoop/src/sqoop/api/driver.py

@@ -15,10 +15,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-try:
-  import json
-except ImportError:
-  import simplejson as json
+import json
 import logging
 import socket
 

+ 1 - 4
apps/sqoop/src/sqoop/api/job.py

@@ -15,10 +15,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-try:
-  import json
-except ImportError:
-  import simplejson as json
+import json
 import logging
 import socket
 

+ 1 - 4
apps/sqoop/src/sqoop/api/link.py

@@ -15,10 +15,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-try:
-  import json
-except ImportError:
-  import simplejson as json
+import json
 import logging
 import socket
 

+ 1 - 4
apps/sqoop/src/sqoop/api/submission.py

@@ -15,10 +15,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-try:
-  import json
-except ImportError:
-  import simplejson as json
+import json
 import logging
 import socket
 

+ 1 - 4
apps/sqoop/src/sqoop/client/base.py

@@ -18,10 +18,7 @@ import logging
 import posixpath
 import threading
 import time
-try:
-  import json
-except ImportError:
-  import simplejson as json
+import json
 
 from django.utils.translation import ugettext as _
 

+ 2 - 5
apps/sqoop/src/sqoop/client/resource.py

@@ -14,10 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-try:
-  import json
-except ImportError:
-  import simplejson as json
+import json
 
 from django.utils.translation import ugettext as _
 
@@ -102,4 +99,4 @@ class SqoopResource(Resource):
   def _make_headers(self, contenttype=None):
     if contenttype:
       return { 'Content-Type': contenttype }
-    return None
+    return None

+ 3 - 3
apps/zookeeper/src/zookeeper/rest.py

@@ -17,7 +17,7 @@
 
 import urllib2
 import urllib
-import simplejson
+import json
 
 from contextlib import contextmanager
 
@@ -172,7 +172,7 @@ class ZooKeeper(object):
         """ Send a GET request and convert errors to exceptions """
         try:
             req = urllib2.urlopen(uri)
-            resp = simplejson.load(req)
+            resp = json.load(req)
 
             if 'Error' in resp:
                raise ZooKeeper.Error(resp['Error'])
@@ -191,7 +191,7 @@ class ZooKeeper(object):
             if data is not None:
                 req.add_data(data)
 
-            resp = simplejson.load(urllib2.urlopen(req))
+            resp = json.load(urllib2.urlopen(req))
             if 'Error' in resp:
                 raise ZooKeeper.Error(resp['Error'])
             return resp

+ 2 - 2
desktop/core/src/desktop/lib/django_forms.py

@@ -18,7 +18,7 @@
 # Extra form fields and widgets.
 
 import logging
-import simplejson
+import json
 import urllib
 
 from django.forms import Widget, Field
@@ -527,4 +527,4 @@ class DependencyAwareForm(forms.Form):
     return [ data(*x) for x in self.dependencies ]
 
   def render_dep_metadata(self):
-    return urllib.quote_plus(simplejson.dumps(self._calculate_data(), separators=(',', ':')))
+    return urllib.quote_plus(json.dumps(self._calculate_data(), separators=(',', ':')))

+ 2 - 2
desktop/core/src/desktop/lib/django_test_util.py

@@ -20,7 +20,7 @@ Common utilities for testing Desktop django apps.
 
 import logging
 import re
-import simplejson
+import json
 
 import django.test.client
 from django.contrib.auth.models import User, Group
@@ -33,7 +33,7 @@ class Client(django.test.client.Client):
   """
   def get_json(self, *args, **kwargs):
     response = self.get(*args, **kwargs)
-    return simplejson.JSONDecoder().decode(response.content)
+    return json.JSONDecoder().decode(response.content)
 
 def assert_ok_response(response):
   """

+ 3 - 3
desktop/core/src/desktop/lib/djangojson.py

@@ -18,7 +18,7 @@
 from django.forms import util
 from django.forms import fields
 from django import forms
-import simplejson
+import json
 
 class JsonFormField(fields.CharField):
   """
@@ -41,8 +41,8 @@ class JsonFormField(fields.CharField):
   def clean(self, value):
     value = super(JsonFormField, self).clean(value)
     try:
-      simplejson.loads(value)
+      json.loads(value)
     except ValueError, e:
       raise util.ValidationError(e)
     return value
-  
+  

+ 5 - 6
desktop/core/src/desktop/lib/djangothrift.py

@@ -34,12 +34,12 @@
 # This is frustrating visually, since the JSON ends up double-quoted.
 # It also means that you have to dirty your object with an extra __unicode__
 # field.  You can do it, like so:
-#   tft.__unicode__ = lambda: simplejson.dumps(thrift_util.thrift2json(tft))
+#   tft.__unicode__ = lambda: json.dumps(thrift_util.thrift2json(tft))
 # but then your field is no longer equal to a Thrift object that hasn't
 # been through this dirtying, and that's bad.
 # So, don't use JSON serialization, and use XML serialization instead.
 
-import simplejson
+import json
 
 import thrift_util
 
@@ -69,7 +69,7 @@ class ThriftField(models.TextField):
     if not isinstance(value, basestring): 
       return value
 
-    jsonable = simplejson.loads(value)
+    jsonable = json.loads(value)
     tft = thrift_util.jsonable2thrift(jsonable, self.thrift_class)
     return tft
 
@@ -77,14 +77,13 @@ class ThriftField(models.TextField):
     if value is None: 
       return None
     jsonable = thrift_util.thrift2json(value)
-    json = simplejson.dumps(jsonable)
-    return json
+    return json.dumps(jsonable)
 
   def value_to_string(self, obj):
     """
     Used by XML serialization.
     """
-    return simplejson.dumps(thrift_util.thrift2json(self._get_val_from_obj(obj)))
+    return json.dumps(thrift_util.thrift2json(self._get_val_from_obj(obj)))
 
 
 # See http://south.aeracode.org/docs/customfields.html#extending-introspection

+ 1 - 4
desktop/core/src/desktop/lib/json_utils.py

@@ -15,10 +15,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-try:
-  import json
-except ImportError:
-  import simplejson as json
+import json
 
 
 ##

+ 1 - 4
desktop/libs/hadoop/src/hadoop/fs/exceptions.py

@@ -15,10 +15,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-try:
-  import json
-except:
-  import simplejson as json
+import json
 
 from desktop.lib.exceptions import StructuredException
 from desktop.lib.rest.http_client import RestException

+ 2 - 2
desktop/libs/hadoop/src/hadoop/mini_cluster.py

@@ -48,7 +48,7 @@ import shutil
 import socket
 import time
 import tempfile
-import simplejson
+import json
 import lxml.etree
 import urllib2
 
@@ -235,7 +235,7 @@ rpc.class=org.apache.hadoop.metrics.spi.NoEmitMetricsContext
       while not details:
         try:
           details_file.seek(0)
-          details = simplejson.load(details_file)
+          details = json.load(details_file)
         except ValueError:
           pass
         if self.clusterproc.poll() is not None or (not DEBUG_HADOOP and (time.time() - start) > MAX_CLUSTER_STARTUP_TIME):

+ 0 - 1
docs/manual.txt

@@ -64,7 +64,6 @@ cyrus-sasl-gssapi,libsasl2-modules-gssapi-mit,libsasl2-modules-gssapi-mit
 mysql-devel,libmysqlclient-dev,libmysqlclient-dev
 python-devel,python-dev,python-dev
 python-setuptools,python-setuptools,python-setuptools
-python-simplejson,python-simplejson,python-simplejson
 sqlite-devel,libsqlite3-dev,libsqlite3-dev
 ant,ant,ant
 libsasl2-dev,cyrus-sasl-devel,libsasl2-dev

+ 0 - 1
ext/thirdparty/README.md

@@ -40,7 +40,6 @@ Checked-in third party dependencies
 |Y|requests|2.0.0|ASL2|https://github.com/kennethreitz/requests/|
 |Y|Shakespeares Sonnets|?|Public Domain from Gutenberg|http://www.gutenberg.org/dirs/etext97/wssnt10.txt|
 |Y|sasl|0.1.1|Apache|http://pypi.python.org/pypi/sasl/0.1.1|
-|Y|simplejson|2.0.9|MIT|http://pypi.python.org/packages/source/s/simplejson/simplejson-2.0.9.tar.gz|
 |Y|South|0.7|Apache|http://south.aeracode.org/|
 |Y|ssl|1.15|Python|http://pypi.python.org/pypi/ssl/1.15|
 |Y|tablib|0.9.11|MIT|http://docs.python-tablib.org/en/latest/|

+ 1 - 4
tools/app_reg/registry.py

@@ -22,10 +22,7 @@ Registry for the applications
 import glob
 import logging
 import os
-try:
-  import json
-except ImportError:
-  import simplejson as json
+import json
 
 import common