[autotest] Use |json| instead of |simplejson|.

simplejson was moved into the library as of python 2.4. We're now at
python 2.6/2.7, and having to keep installing simplejson everywhere has
slowly turned into a hassle.  Since we can just trivially drop/rename
it, let's do so.

The rpc_interface parts of this change have been vetted, the rest is
done just as a s/simplejson/json/ across the code, which afaik should be
a safe thing to do.

BUG=None
TEST=unit, run_suite
DEPLOY=apache

Change-Id: Iab35f71157e7e5cd3be5291c776b07eb3283be8e
Reviewed-on: https://gerrit.chromium.org/gerrit/46424
Tested-by: Aviv Keshet <akeshet@chromium.org>
Reviewed-by: Alex Miller <milleral@chromium.org>
Commit-Queue: Aviv Keshet <akeshet@chromium.org>
diff --git a/frontend/afe/json_rpc/proxy.py b/frontend/afe/json_rpc/proxy.py
index 718bac3..cbb60e9 100644
--- a/frontend/afe/json_rpc/proxy.py
+++ b/frontend/afe/json_rpc/proxy.py
@@ -73,9 +73,9 @@
         return ServiceProxy(self.__serviceURL, name, self.__headers)
 
     def __call__(self, *args, **kwargs):
-        # pull in simplejson imports lazily so that the library isn't required
+        # pull in json imports lazily so that the library isn't required
         # unless you actually need to do encoding and decoding
-        from simplejson import decoder, encoder
+        from json import decoder, encoder
 
         postdata = encoder.JSONEncoder().encode({"method": self.__serviceName,
                                                 'params': args + (kwargs,),
diff --git a/frontend/afe/json_rpc/serviceHandler.py b/frontend/afe/json_rpc/serviceHandler.py
index 4d85fc0..50ea45f 100644
--- a/frontend/afe/json_rpc/serviceHandler.py
+++ b/frontend/afe/json_rpc/serviceHandler.py
@@ -21,7 +21,7 @@
 
 import traceback
 
-from simplejson import decoder, encoder
+from json import decoder, encoder
 
 def customConvertJson(value):
     """\
diff --git a/frontend/perf-dashboard/extract_perf.py b/frontend/perf-dashboard/extract_perf.py
index b5afb88..a289fdf 100644
--- a/frontend/perf-dashboard/extract_perf.py
+++ b/frontend/perf-dashboard/extract_perf.py
@@ -21,7 +21,7 @@
 import optparse
 import os
 import re
-import simplejson
+import json
 import sys
 import time
 
@@ -118,7 +118,7 @@
     result_out.append(perf_items)
     file_name = os.path.join(test_dir, result_dict['platform'] + '.txt')
     with open(file_name, 'a') as fp:
-        fp.write(simplejson.dumps(result_out) + '\n')
+        fp.write(json.dumps(result_out) + '\n')
 
     with open(os.path.join(output_dir, _COMPLETED_ID_FILE_NAME), 'a') as fp:
         fp.write(job_id + '\n')
@@ -246,7 +246,7 @@
     """
     charts = {}
     with open(_CHART_CONFIG_FILE, 'r') as fp:
-        charts = simplejson.loads(fp.read())
+        charts = json.loads(fp.read())
 
     # Compute the oldest date for the perf values that we want to consider.
     oldest_db_lookup_date = (
diff --git a/frontend/perf-dashboard/generate_perf_graphs.py b/frontend/perf-dashboard/generate_perf_graphs.py
index 44c09ae..d299a8c 100644
--- a/frontend/perf-dashboard/generate_perf_graphs.py
+++ b/frontend/perf-dashboard/generate_perf_graphs.py
@@ -28,7 +28,7 @@
 import os
 import re
 import shutil
-import simplejson
+import json
 import sys
 import urllib
 import urllib2
@@ -315,7 +315,7 @@
         }
         if units:
             new_dash_entry['units'] = units
-        json_string = simplejson.dumps([new_dash_entry], indent=2)
+        json_string = json.dumps([new_dash_entry], indent=2)
         params = urllib.urlencode({'data': json_string})
         fp = None
         try:
@@ -411,7 +411,7 @@
               'important': False,
             }]
             with open(os.path.join(output_path, 'graphs.dat'), 'w') as f:
-                f.write(simplejson.dumps(graphs, indent=2))
+                f.write(json.dumps(graphs, indent=2))
 
             # Add symlinks to the plotting code.
             for slink, target in _SYMLINK_LIST:
@@ -468,7 +468,7 @@
                 # Output data point to be displayed on the current (deprecated)
                 # dashboard.
                 with open(summary_file, 'a') as f:
-                    f.write(simplejson.dumps(entry) + '\n')
+                    f.write(json.dumps(entry) + '\n')
 
 
 def process_perf_data_files(file_names, test_name, master_name, completed_ids,
@@ -505,7 +505,7 @@
     for file_name in file_names:
         with open(file_name, 'r') as fp:
             for line in fp.readlines():
-                info = simplejson.loads(line.strip())
+                info = json.loads(line.strip())
                 job_id = info[0]
                 job_name = info[1]
                 platform = info[2]
@@ -559,7 +559,7 @@
     @param output_data_dir: A directory in which to output data files.
 
     """
-    charts = simplejson.loads(open(_CHART_CONFIG_FILE, 'r').read())
+    charts = json.loads(open(_CHART_CONFIG_FILE, 'r').read())
 
     # Identify all the job IDs already processed in the graphs, so that we don't
     # add that data again.
@@ -577,7 +577,7 @@
     rev_num_file = os.path.join(output_data_dir, _REV_NUM_FILE_NAME)
     if os.path.exists(rev_num_file):
         with open(rev_num_file, 'r') as fp:
-            summary_id_to_rev_num = simplejson.loads(fp.read())
+            summary_id_to_rev_num = json.loads(fp.read())
 
     # TODO (dennisjeffrey): If we have to add another "test_name_to_X"
     # dictionary to the list below, we should simplify this code to create a
@@ -635,7 +635,7 @@
     # Store the latest revision numbers for each test/platform/release
     # combination, to be used on the next invocation of this script.
     with open(rev_num_file, 'w') as fp:
-        fp.write(simplejson.dumps(summary_id_to_rev_num, indent=2))
+        fp.write(json.dumps(summary_id_to_rev_num, indent=2))
 
     logging.info('Added info for %d new jobs to the graphs!', newly_added_count)
 
diff --git a/frontend/shared/json_html_formatter.py b/frontend/shared/json_html_formatter.py
index b4b7364..6ef0736 100644
--- a/frontend/shared/json_html_formatter.py
+++ b/frontend/shared/json_html_formatter.py
@@ -29,7 +29,7 @@
 """
 
 import re
-import simplejson
+import json
 
 _HTML_DOCUMENT_TEMPLATE = """
 <!DOCTYPE html>
@@ -134,7 +134,7 @@
         if request.GET.get('alt', None) != 'json-html':
             return response
 
-        json_value = simplejson.loads(response.content)
+        json_value = json.loads(response.content)
         html = JsonHtmlFormatter().json_to_html(json_value)
         response.content = html
         response['Content-type'] = 'text/html'
diff --git a/frontend/shared/resource_lib.py b/frontend/shared/resource_lib.py
index 86cc583..254e92f 100644
--- a/frontend/shared/resource_lib.py
+++ b/frontend/shared/resource_lib.py
@@ -3,7 +3,7 @@
 import django.core.exceptions
 from django.core import urlresolvers
 from django.utils import datastructures
-import simplejson
+import json
 from autotest_lib.frontend.shared import exceptions, query_lib
 from autotest_lib.frontend.afe import model_logic
 
@@ -203,7 +203,7 @@
         query_parameters = self._query_parameters_response()
         if query_parameters:
             content['query_parameters'] = query_parameters
-        encoded_content = simplejson.dumps(content)
+        encoded_content = json.dumps(content)
         return http.HttpResponse(encoded_content,
                                  content_type=_JSON_CONTENT_TYPE)
 
@@ -214,7 +214,7 @@
         raw_data = self._request.raw_post_data
         if content_type == _JSON_CONTENT_TYPE:
             try:
-                raw_dict = simplejson.loads(raw_data)
+                raw_dict = json.loads(raw_data)
             except ValueError, exc:
                 raise exceptions.BadRequest('Error decoding request body: '
                                             '%s\n%r' % (exc, raw_data))
@@ -228,7 +228,7 @@
                 value = values[-1] # take last value if multiple were given
                 try:
                     # attempt to parse numbers, booleans and nulls
-                    raw_dict[key] = simplejson.loads(value)
+                    raw_dict[key] = json.loads(value)
                 except ValueError:
                     # otherwise, leave it as a string
                     raw_dict[key] = value
diff --git a/frontend/shared/resource_test_utils.py b/frontend/shared/resource_test_utils.py
index 8cb742f..f52cd3b 100644
--- a/frontend/shared/resource_test_utils.py
+++ b/frontend/shared/resource_test_utils.py
@@ -1,5 +1,5 @@
 import operator, unittest
-import simplejson
+import json
 from django.test import client
 from autotest_lib.frontend.afe import frontend_test_utils, models as afe_models
 
@@ -53,7 +53,7 @@
         if 'data' in kwargs:
             kwargs.setdefault('content_type', 'application/json')
             if kwargs['content_type'] == 'application/json':
-                kwargs['data'] = simplejson.dumps(kwargs['data'])
+                kwargs['data'] = json.dumps(kwargs['data'])
 
         if uri.startswith('http://'):
             full_uri = uri
@@ -72,7 +72,7 @@
             return response.content
 
         try:
-            return simplejson.loads(response.content)
+            return json.loads(response.content)
         except ValueError:
             self.fail('Invalid reponse body: %s' % response.content)
 
diff --git a/frontend/tko/graphing_utils.py b/frontend/tko/graphing_utils.py
index 44a5e11..17a6ceb 100644
--- a/frontend/tko/graphing_utils.py
+++ b/frontend/tko/graphing_utils.py
@@ -22,7 +22,7 @@
 import StringIO, colorsys, PIL.Image, PIL.ImageChops
 from autotest_lib.frontend.afe import readonly_connection
 from autotest_lib.frontend.afe.model_logic import ValidationError
-from simplejson import encoder
+from json import encoder
 from autotest_lib.client.common_lib import global_config
 from autotest_lib.frontend.tko import models, tko_rpc_utils