Remove deprecated code. (#693)

* Remove deprecated code.
diff --git a/mobly/controllers/android_device_lib/jsonrpc_client_base.py b/mobly/controllers/android_device_lib/jsonrpc_client_base.py
index 6d8a9d5..6cecaa8 100644
--- a/mobly/controllers/android_device_lib/jsonrpc_client_base.py
+++ b/mobly/controllers/android_device_lib/jsonrpc_client_base.py
@@ -223,17 +223,11 @@
             socket.timeout: Raised when the socket waits to long for connection.
             ProtocolError: Raised when there is an error in the protocol.
         """
-        # socket.create_connection throws different exceptions in Python 2/3
-        # TODO: Use ConnectionRefusedError directly once PY2 is deprecated.
-        ExceptionAlias = socket.error
-        if sys.version_info >= (3, 0):
-          ExceptionAlias = ConnectionRefusedError
-
         self._counter = self._id_counter()
         try:
           self._conn = socket.create_connection(('localhost', self.host_port),
                                                 _SOCKET_CONNECTION_TIMEOUT)
-        except ExceptionAlias as err:
+        except ConnectionRefusedError as err:
           # Retry using '127.0.0.1' for IPv4 enabled machines that only resolve
           # 'localhost' to '[::1]'.
           self.log.debug('Failed to connect to localhost, trying 127.0.0.1: {}'
diff --git a/mobly/controllers/android_device_lib/services/logcat.py b/mobly/controllers/android_device_lib/services/logcat.py
index 0784674..fd8d644 100644
--- a/mobly/controllers/android_device_lib/services/logcat.py
+++ b/mobly/controllers/android_device_lib/services/logcat.py
@@ -100,23 +100,6 @@
         high = mobly_logger.logline_timestamp_comparator(end_time, target) >= 0
         return low and high
 
-    def create_per_test_excerpt(self, current_test_info):
-        """Convenient method for creating excerpts of adb logcat.
-
-        .. deprecated:: 1.10
-           Use :func:`create_output_excerpts` instead.
-
-        This copies logcat lines from self.adb_logcat_file_path to an excerpt
-        file, starting from the location where the previous excerpt ended.
-
-        To use this feature, call this method at the end of: `setup_class`,
-        `teardown_test`, and `teardown_class`.
-
-        Args:
-            current_test_info: `self.current_test_info` in a Mobly test.
-        """
-        self.create_output_excerpts(current_test_info)
-
     def create_output_excerpts(self, test_info):
         """Convenient method for creating excerpts of adb logcat.
 
@@ -166,59 +149,6 @@
             else:
                 raise
 
-    def cat_adb_log(self, tag, begin_time):
-        """Takes an excerpt of the adb logcat log from a certain time point to
-        current time.
-
-        .. deprecated:: 1.10
-            Use :func:`create_output_excerpts` instead.
-
-        Args:
-            tag: An identifier of the time period, usualy the name of a test.
-            begin_time: Logline format timestamp of the beginning of the time
-                period.
-
-        Returns:
-            String, full path to the excerpt file created.
-        """
-        if not self.adb_logcat_file_path:
-            raise Error(
-                self._ad,
-                'Attempting to cat adb log when none has been collected.')
-        end_time = mobly_logger.get_log_line_timestamp()
-        self._ad.log.debug('Extracting adb log from logcat.')
-        adb_excerpt_path = os.path.join(self._ad.log_path, 'AdbLogExcerpts')
-        utils.create_dir(adb_excerpt_path)
-        out_name = '%s,%s.txt' % (tag, begin_time)
-        out_name = mobly_logger.sanitize_filename(out_name)
-        full_adblog_path = os.path.join(adb_excerpt_path, out_name)
-        with io.open(full_adblog_path, 'w', encoding='utf-8') as out:
-            in_file = self.adb_logcat_file_path
-            with io.open(in_file, 'r', encoding='utf-8',
-                         errors='replace') as f:
-                in_range = False
-                while True:
-                    line = None
-                    try:
-                        line = f.readline()
-                        if not line:
-                            break
-                    except:
-                        continue
-                    line_time = line[:mobly_logger.log_line_timestamp_len]
-                    if not mobly_logger.is_valid_logline_timestamp(line_time):
-                        continue
-                    if self._is_timestamp_in_range(line_time, begin_time,
-                                                   end_time):
-                        in_range = True
-                        if not line.endswith('\n'):
-                            line += '\n'
-                        out.write(line)
-                    else:
-                        if in_range:
-                            break
-        return full_adblog_path
-
     def _assert_not_running(self):
         """Asserts the logcat service is not running.
 
diff --git a/tests/mobly/controllers/android_device_lib/services/logcat_test.py b/tests/mobly/controllers/android_device_lib/services/logcat_test.py
index 93f883a..4401c9a 100755
--- a/tests/mobly/controllers/android_device_lib/services/logcat_test.py
+++ b/tests/mobly/controllers/android_device_lib/services/logcat_test.py
@@ -355,90 +355,6 @@
         self.assertIsNone(logcat_service.adb_logcat_file_path)
 
     @mock.patch('mobly.controllers.android_device_lib.adb.AdbProxy',
-                return_value=mock_android_device.MockAdbProxy('1'))
-    @mock.patch('mobly.controllers.android_device_lib.fastboot.FastbootProxy',
-                return_value=mock_android_device.MockFastbootProxy('1'))
-    @mock.patch('mobly.utils.start_standing_subprocess',
-                return_value='process')
-    @mock.patch('mobly.utils.stop_standing_subprocess')
-    @mock.patch.object(logcat.Logcat, '_open_logcat_file')
-    @mock.patch('mobly.logger.get_log_line_timestamp',
-                return_value=MOCK_ADB_LOGCAT_END_TIME)
-    def test_cat_adb_log(self, mock_timestamp_getter, open_logcat_mock,
-                         stop_proc_mock, start_proc_mock, FastbootProxy,
-                         MockAdbProxy):
-        """Verifies that AndroidDevice.cat_adb_log loads the correct adb log
-        file, locates the correct adb log lines within the given time range,
-        and writes the lines to the correct output file.
-        """
-        mock_serial = '1'
-        ad = android_device.AndroidDevice(serial=mock_serial)
-        logcat_service = logcat.Logcat(ad)
-        logcat_service._enable_logpersist()
-        # Direct the log path of the ad to a temp dir to avoid racing.
-        logcat_service._ad._log_path = self.tmp_dir
-        # Expect error if attempted to cat adb log before starting adb logcat.
-        expected_msg = ('.* Attempting to cat adb log when none'
-                        ' has been collected.')
-        with self.assertRaisesRegex(logcat.Error, expected_msg):
-            logcat_service.cat_adb_log('some_test', MOCK_ADB_LOGCAT_BEGIN_TIME)
-        logcat_service.start()
-        utils.create_dir(ad.log_path)
-        mock_adb_log_path = logcat_service.adb_logcat_file_path
-        with io.open(mock_adb_log_path, 'w', encoding='utf-8') as f:
-            f.write(MOCK_ADB_LOGCAT)
-        cat_file_path = logcat_service.cat_adb_log('some_test',
-                                                   MOCK_ADB_LOGCAT_BEGIN_TIME)
-        with io.open(cat_file_path, 'r', encoding='utf-8') as f:
-            actual_cat = f.read()
-        self.assertEqual(actual_cat, ''.join(MOCK_ADB_LOGCAT_CAT_RESULT))
-        # Stops adb logcat.
-        logcat_service.stop()
-
-    @mock.patch('mobly.controllers.android_device_lib.adb.AdbProxy',
-                return_value=mock_android_device.MockAdbProxy('1'))
-    @mock.patch('mobly.controllers.android_device_lib.fastboot.FastbootProxy',
-                return_value=mock_android_device.MockFastbootProxy('1'))
-    @mock.patch('mobly.utils.start_standing_subprocess',
-                return_value='process')
-    @mock.patch('mobly.utils.stop_standing_subprocess')
-    @mock.patch.object(logcat.Logcat, '_open_logcat_file')
-    @mock.patch('mobly.logger.get_log_line_timestamp',
-                return_value=MOCK_ADB_LOGCAT_END_TIME)
-    def test_cat_adb_log_with_unicode(self, mock_timestamp_getter,
-                                      open_logcat_mock, stop_proc_mock,
-                                      start_proc_mock, FastbootProxy,
-                                      MockAdbProxy):
-        """Verifies that AndroidDevice.cat_adb_log loads the correct adb log
-        file, locates the correct adb log lines within the given time range,
-        and writes the lines to the correct output file.
-        """
-        mock_serial = '1'
-        ad = android_device.AndroidDevice(serial=mock_serial)
-        logcat_service = logcat.Logcat(ad)
-        logcat_service._enable_logpersist()
-        # Direct the log path of the ad to a temp dir to avoid racing.
-        logcat_service._ad._log_path = self.tmp_dir
-        # Expect error if attempted to cat adb log before starting adb logcat.
-        expected_msg = ('.* Attempting to cat adb log when none'
-                        ' has been collected.')
-        with self.assertRaisesRegex(logcat.Error, expected_msg):
-            logcat_service.cat_adb_log('some_test', MOCK_ADB_LOGCAT_BEGIN_TIME)
-        logcat_service.start()
-        utils.create_dir(ad.log_path)
-        mock_adb_log_path = logcat_service.adb_logcat_file_path
-        with io.open(mock_adb_log_path, 'w', encoding='utf-8') as f:
-            f.write(MOCK_ADB_UNICODE_LOGCAT)
-        cat_file_path = logcat_service.cat_adb_log('some_test',
-                                                   MOCK_ADB_LOGCAT_BEGIN_TIME)
-        with io.open(cat_file_path, 'r', encoding='utf-8') as f:
-            actual_cat = f.read()
-        self.assertEqual(actual_cat,
-                         ''.join(MOCK_ADB_UNICODE_LOGCAT_CAT_RESULT))
-        # Stops adb logcat.
-        logcat_service.stop()
-
-    @mock.patch('mobly.controllers.android_device_lib.adb.AdbProxy',
                 return_value=mock.MagicMock())
     @mock.patch('mobly.controllers.android_device_lib.fastboot.FastbootProxy',
                 return_value=mock_android_device.MockFastbootProxy('1'))