[autotest] Simplify access to readonly_connection

After refactoring the way readonly_connection works in
CL:223393 some uses of it can be shortened.

BUG=None
DEPLOY=apache,scheduler,host_scheduler,shard_client
TEST=Ran suites, syncdb, apache restart and dummy suite.

Change-Id: I461345ecb362bd54740417f0016a64072581a513
Reviewed-on: https://chromium-review.googlesource.com/223394
Tested-by: Jakob Jülich <jakobjuelich@chromium.org>
Reviewed-by: Prashanth B <beeps@chromium.org>
Commit-Queue: Jakob Jülich <jakobjuelich@chromium.org>
diff --git a/frontend/croschart/labtest/models.py b/frontend/croschart/labtest/models.py
index e0d8aae..ee740c5 100644
--- a/frontend/croschart/labtest/models.py
+++ b/frontend/croschart/labtest/models.py
@@ -113,7 +113,7 @@
     gviz_data_table_users = gviz_data_table_users.ToJSon(keys_in_order)
     return {'jobs': gviz_data_table_jobs, 'users': gviz_data_table_users}
 
-  cursor = readonly_connection.connection().cursor()
+  cursor = readonly_connection.cursor()
   cursor.execute(query)
   test_data, user_data = AggregateTests(cursor.fetchall())
   gviz_data_table = ToGVizJsonTable(test_data, user_data)
diff --git a/frontend/croschart/perfchart/models.py b/frontend/croschart/perfchart/models.py
index af570bf..e63e07c 100644
--- a/frontend/croschart/perfchart/models.py
+++ b/frontend/croschart/perfchart/models.py
@@ -81,7 +81,7 @@
     gviz_data_table = gviz_data_table.ToJSon(keys_in_order)
     return gviz_data_table
 
-  cursor = readonly_connection.connection().cursor()
+  cursor = readonly_connection.cursor()
   cursor.execute('%s %s' % (query, query_order))
   job_tags, build_data = AggregateBuilds(test_keys, chrome_versions,
                                          cursor.fetchall())
diff --git a/frontend/croschart/releasereport/models.py b/frontend/croschart/releasereport/models.py
index 50a3325..898d881 100644
--- a/frontend/croschart/releasereport/models.py
+++ b/frontend/croschart/releasereport/models.py
@@ -252,7 +252,7 @@
     return gviz_data_table
 
   # Now massage the returned data into a gviz data table.
-  cursor = readonly_connection.connection().cursor()
+  cursor = readonly_connection.cursor()
   cursor.execute('%s %s' % (query, query_order))
   builds, build_data = AggregateBuilds(extra.get('lowhigh', None),
                                        chrome_versions,
diff --git a/frontend/frontend_unittest.py b/frontend/frontend_unittest.py
index c8b4cf1..4d1d902 100755
--- a/frontend/frontend_unittest.py
+++ b/frontend/frontend_unittest.py
@@ -4,7 +4,7 @@
 import common
 from autotest_lib.frontend import setup_django_environment
 from autotest_lib.frontend import setup_test_environment
-from autotest_lib.frontend.afe import test, readonly_connection
+from autotest_lib.frontend.afe import test
 from autotest_lib.client.common_lib import global_config
 
 _APP_DIR = os.path.join(os.path.dirname(__file__), 'afe')
diff --git a/frontend/tko/graphing_utils.py b/frontend/tko/graphing_utils.py
index cd5c70e..9d1a9fb 100644
--- a/frontend/tko/graphing_utils.py
+++ b/frontend/tko/graphing_utils.py
@@ -537,7 +537,7 @@
     TODO(showard): move some/all of this logic into methods on MetricsPlot
     """
     query = plot_info.query_dict['__main__']
-    cursor = readonly_connection.connection().cursor()
+    cursor = readonly_connection.cursor()
     cursor.execute(query)
 
     if not cursor.rowcount:
@@ -662,7 +662,7 @@
     TODO(showard): move much or all of this into methods on
     QualificationHistogram
     """
-    cursor = readonly_connection.connection().cursor()
+    cursor = readonly_connection.cursor()
     cursor.execute(plot_info.query)
 
     if not cursor.rowcount:
diff --git a/frontend/tko/models.py b/frontend/tko/models.py
index af88dee..81e2928 100644
--- a/frontend/tko/models.py
+++ b/frontend/tko/models.py
@@ -65,7 +65,7 @@
 
         """
         sql, params = self._get_group_query_sql(query, group_by)
-        cursor = readonly_connection.connection().cursor()
+        cursor = readonly_connection.cursor()
         cursor.execute(sql, params)
         field_names = self._get_column_names(cursor)
         row_dicts = [dict(zip(field_names, row)) for row in cursor.fetchall()]
@@ -116,7 +116,7 @@
 
         """
         sql, params = self._get_num_groups_sql(query, group_by)
-        cursor = readonly_connection.connection().cursor()
+        cursor = readonly_connection.cursor()
         cursor.execute(sql, params)
         return self._cursor_rowcount(cursor)
 
diff --git a/frontend/tko/rpc_interface.py b/frontend/tko/rpc_interface.py
index 25a2f40..612352d 100644
--- a/frontend/tko/rpc_interface.py
+++ b/frontend/tko/rpc_interface.py
@@ -229,7 +229,7 @@
                  GROUP BY job_name, IF (status = 'GOOD', status, 'FAIL')'''
             % sql_list)
 
-    cursor = readonly_connection.connection().cursor()
+    cursor = readonly_connection.cursor()
     cursor.execute(query, job_names)
     results = rpc_utils.fetchall_as_list_of_dicts(cursor)
 
@@ -258,7 +258,7 @@
                  GROUP BY IF (status = 'GOOD', status, 'FAIL')'''
 
     summaries = {}
-    cursor = readonly_connection.connection().cursor()
+    cursor = readonly_connection.cursor()
     for job_name in job_names:
         cursor.execute(query, job_name)
         results = rpc_utils.fetchall_as_list_of_dicts(cursor)
@@ -312,7 +312,7 @@
 # client.  We should come up with a more opaque RPC for that place to call and
 # get rid of this.
 def execute_query_with_param(query, param):
-    cursor = readonly_connection.connection().cursor()
+    cursor = readonly_connection.cursor()
     cursor.execute(query, param)
     return cursor.fetchall()