Update acloud_kernel and goldfish_compute_client + others to be pylint compliant.

- According to 4 spaces, the code modified base on the rule.
- Added pylint disable comments to avoid pylint error check.

Bug: None
Test: run pylint tools base on the file pylintrc CL 688459
      pylint public/acloud_kernel/acloud_kernel.py
      pylint public/acloud_kernel/kernel_swapper_test.py
      pylint public/acloud_kernel/kernel_swapper.py
      pylint internal/lib/goldfish_compute_client.py
      pylint internal/lib/goldfish_compute_client_test.py
      pylint internal/lib/driver_test_lib.py
      pylint internal/lib/utils.py
      pylint internal/lib/utils_test.py

Change-Id: Iab1d9aaed5d52f598feede9ab399af87b0fcdc81
diff --git a/internal/lib/driver_test_lib.py b/internal/lib/driver_test_lib.py
index 4ca1bfc..a9f212c 100644
--- a/internal/lib/driver_test_lib.py
+++ b/internal/lib/driver_test_lib.py
@@ -13,11 +13,9 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-
 """Driver test library."""
-
-import mock
 import unittest
+import mock
 
 
 class BaseDriverTest(unittest.TestCase):
diff --git a/internal/lib/goldfish_compute_client.py b/internal/lib/goldfish_compute_client.py
index 01278fc..9697d8e 100644
--- a/internal/lib/goldfish_compute_client.py
+++ b/internal/lib/goldfish_compute_client.py
@@ -13,7 +13,6 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-
 """A client that manages Goldfish Virtual Device on compute engine.
 
 ** GoldfishComputeClient **
@@ -37,12 +36,11 @@
        goldfish_compute_client.GoldfishComputeClient
 
 
-TODO(jansen): This class should likely be merged with CvdComputeClient
+TODO: This class should likely be merged with CvdComputeClient
 """
 
 import getpass
 import logging
-import os
 
 from acloud.internal.lib import android_compute_client
 from acloud.internal.lib import gcompute_client
@@ -52,150 +50,151 @@
 
 
 class GoldfishComputeClient(android_compute_client.AndroidComputeClient):
-  """Client that manages Goldfish based Android Virtual Device."""
+    """Client that manages Goldfish based Android Virtual Device.
 
-  # To determine if the boot failed
-  BOOT_FAILED_MSG = "VIRTUAL_DEVICE_FAILED"
-
-  # To determine the failure reason
-  # If the emulator build is not available
-  EMULATOR_FETCH_FAILED_MSG = "EMULATOR_FETCH_FAILED"
-  # If the system image build is not available
-  ANDROID_FETCH_FAILED_MSG = "ANDROID_FETCH_FAILED"
-  # If the emulator could not boot in time
-  BOOT_TIMEOUT_MSG = "VIRTUAL_DEVICE_BOOT_FAILED"
-
-  def __init__(self, acloud_config, oauth2_credentials):
-    """Initialize.
-
-    Args:
-      acloud_config: An AcloudConfig object.
-      oauth2_credentials: An oauth2client.OAuth2Credentials instance.
+    Attributes:
+        acloud_config: An AcloudConfig object.
+        oauth2_credentials: An oauth2client.OAuth2Credentials instance.
     """
-    super(GoldfishComputeClient, self).__init__(acloud_config,
-                                                oauth2_credentials)
 
-  def _GetDiskArgs(self, disk_name, image_name, image_project, disk_size_gb):
-    """Helper to generate disk args that is used to create an instance.
+    # To determine if the boot failed
+    BOOT_FAILED_MSG = "VIRTUAL_DEVICE_FAILED"
 
-    Args:
-      disk_name: A string
-      image_name: A string
-      image_project: A string
-      disk_size_gb: An integer
+    # To determine the failure reason
+    # If the emulator build is not available
+    EMULATOR_FETCH_FAILED_MSG = "EMULATOR_FETCH_FAILED"
+    # If the system image build is not available
+    ANDROID_FETCH_FAILED_MSG = "ANDROID_FETCH_FAILED"
+    # If the emulator could not boot in time
+    BOOT_TIMEOUT_MSG = "VIRTUAL_DEVICE_BOOT_FAILED"
 
-    Returns:
-      A dictionary representing disk args.
-    """
-    return [{
-        "type": "PERSISTENT",
-        "boot": True,
-        "mode": "READ_WRITE",
-        "autoDelete": True,
-        "initializeParams": {
-            "diskName":
+    #pylint: disable=signature-differs
+    def _GetDiskArgs(self, disk_name, image_name, image_project, disk_size_gb):
+        """Helper to generate disk args that is used to create an instance.
+
+        Args:
+            disk_name: String, the name of disk.
+            image_name: String, the name of the system image.
+            image_project: String, the name of the project where the image.
+            disk_size_gb: Integer, size of the blank data disk in GB.
+
+        Returns:
+            A dictionary representing disk args.
+        """
+        return [{
+            "type": "PERSISTENT",
+            "boot": True,
+            "mode": "READ_WRITE",
+            "autoDelete": True,
+            "initializeParams": {
+                "diskName":
                 disk_name,
-            "sourceImage":
+                "sourceImage":
                 self.GetImage(image_name, image_project)["selfLink"],
-            "diskSizeGb":
+                "diskSizeGb":
                 disk_size_gb
-        },
-    }]
+            },
+        }]
+    #pylint: disable=signature-differs
 
-  def CheckBootFailure(self, serial_out, instance):
-    """Overriding method from the parent class.
+    def CheckBootFailure(self, serial_out, instance):
+        """Overriding method from the parent class.
 
-    Args:
-      serial_out: A string
-      instance: A string
+        Args:
+            serial_out: String
+            instance: String
 
-    Raises:
-      Raises an errors.DeviceBootError exception if a failure is detected.
-    """
-    if self.BOOT_FAILED_MSG in serial_out:
-      if self.EMULATOR_FETCH_FAILED_MSG in serial_out:
-        raise errors.DeviceBootError(
-            "Failed to download emulator build. Re-run with a newer build.")
-      if self.ANDROID_FETCH_FAILED_MSG in serial_out:
-        raise errors.DeviceBootError(
-            "Failed to download system image build. Re-run with a newer build.")
-      if self.BOOT_TIMEOUT_MSG in serial_out:
-        raise errors.DeviceBootError(
-            "Emulator timed out while booting.")
+        Raises:
+            Raises an errors.DeviceBootError exception if a failure is detected.
+        """
+        if self.BOOT_FAILED_MSG in serial_out:
+            if self.EMULATOR_FETCH_FAILED_MSG in serial_out:
+                raise errors.DeviceBootError(
+                    "Failed to download emulator build. Re-run with a newer build."
+                )
+            if self.ANDROID_FETCH_FAILED_MSG in serial_out:
+                raise errors.DeviceBootError(
+                    "Failed to download system image build. Re-run with a newer build."
+                )
+            if self.BOOT_TIMEOUT_MSG in serial_out:
+                raise errors.DeviceBootError(
+                    "Emulator timed out while booting.")
 
-  def CreateInstance(self,
-                     instance,
-                     image_name,
-                     image_project,
-                     build_target,
-                     branch,
-                     build_id,
-                     emulator_branch=None,
-                     emulator_build_id=None,
-                     blank_data_disk_size_gb=None,
-                     gpu=None):
-    """Create a goldfish instance given a stable host image and a build id.
+    # pylint: disable=too-many-locals,arguments-differ
+    # TODO: Refactor CreateInstance to pass in an object instead of all these args.
+    def CreateInstance(self,
+                       instance,
+                       image_name,
+                       image_project,
+                       build_target,
+                       branch,
+                       build_id,
+                       emulator_branch=None,
+                       emulator_build_id=None,
+                       blank_data_disk_size_gb=None,
+                       gpu=None):
+        """Create a goldfish instance given a stable host image and a build id.
 
-    Args:
-      instance: instance name.
-      image_name: A string, the name of the system image.
-      image_project: A string, name of the project where the image belongs.
-                     Assume the default project if None.
-      build_target: Target name, e.g. "sdk_phone_x86_64-sdk"
-      branch: Branch name, e.g. "git_pi-dev"
-      build_id: Build id, a string, e.g. "2263051", "P2804227"
-      emulator_branch: emulator branch name, e.g.
-        "aosp-emu-master-dev"
-      emulator_build_id: emulator build id, a string, e.g. "2263051", "P2804227"
-      blank_data_disk_size_gb: Size of the blank data disk in GB.
-      gpu: GPU that should be attached to the instance, or None of no
-        acceleration is needed. e.g. "nvidia-tesla-k80"
-    """
-    self._CheckMachineSize()
+        Args:
+            instance: String, instance name.
+            image_name: String, the name of the system image.
+            image_project: String, name of the project where the image belongs.
+                           Assume the default project if None.
+            build_target: String, target name, e.g. "sdk_phone_x86_64-sdk"
+            branch: String, branch name, e.g. "git_pi-dev"
+            build_id: String, build id, a string, e.g. "2263051", "P2804227"
+            emulator_branch: String, emulator branch name, e.g."aosp-emu-master-dev"
+            emulator_build_id: String, emulator build id, a string, e.g. "2263051", "P2804227"
+            blank_data_disk_size_gb: Integer, size of the blank data disk in GB.
+            gpu: String, GPU that should be attached to the instance, or None of no
+                 acceleration is needed. e.g. "nvidia-tesla-k80"
+        """
+        self._CheckMachineSize()
 
-    # Add space for possible data partition.
-    boot_disk_size_gb = (
-        int(self.GetImage(image_name, image_project)["diskSizeGb"]) +
-        blank_data_disk_size_gb)
-    disk_args = self._GetDiskArgs(instance, image_name, image_project,
-                                  boot_disk_size_gb)
+        # Add space for possible data partition.
+        boot_disk_size_gb = (
+            int(self.GetImage(image_name, image_project)["diskSizeGb"]) +
+            blank_data_disk_size_gb)
+        disk_args = self._GetDiskArgs(instance, image_name, image_project,
+                                      boot_disk_size_gb)
 
-    # Goldfish instances are metadata compatible with cuttlefish devices.
-    # See details goto/goldfish-deployment
-    metadata = self._metadata.copy()
-    resolution = self._resolution.split("x")
+        # Goldfish instances are metadata compatible with cuttlefish devices.
+        # See details goto/goldfish-deployment
+        metadata = self._metadata.copy()
+        resolution = self._resolution.split("x")
 
-    # Note that we use the same metadata naming conventions as cuttlefish
-    metadata["cvd_01_dpi"] = resolution[3]
-    metadata["cvd_01_fetch_android_build_target"] = build_target
-    metadata["cvd_01_fetch_android_bid"] = "{branch}/{build_id}".format(
-        branch=branch, build_id=build_id)
-    if emulator_branch and emulator_build_id:
-      metadata["cvd_01_fetch_emulator_bid"] = "{branch}/{build_id}".format(
-          branch=emulator_branch, build_id=emulator_build_id)
-    metadata["cvd_01_launch"] = "1"
-    metadata["cvd_01_x_res"] = resolution[0]
-    metadata["cvd_01_y_res"] = resolution[1]
+        # Note that we use the same metadata naming conventions as cuttlefish
+        metadata["cvd_01_dpi"] = resolution[3]
+        metadata["cvd_01_fetch_android_build_target"] = build_target
+        metadata["cvd_01_fetch_android_bid"] = "{branch}/{build_id}".format(
+            branch=branch, build_id=build_id)
+        if emulator_branch and emulator_build_id:
+            metadata[
+                "cvd_01_fetch_emulator_bid"] = "{branch}/{build_id}".format(
+                    branch=emulator_branch, build_id=emulator_build_id)
+        metadata["cvd_01_launch"] = "1"
+        metadata["cvd_01_x_res"] = resolution[0]
+        metadata["cvd_01_y_res"] = resolution[1]
 
-    # Add per-instance ssh key
-    if self._ssh_public_key_path:
-      rsa = self._LoadSshPublicKey(self._ssh_public_key_path)
-      logger.info("ssh_public_key_path is specified in config: %s, "
-                  "will add the key to the instance.",
-                  self._ssh_public_key_path)
-      metadata["sshKeys"] = "%s:%s" % (getpass.getuser(), rsa)
-    else:
-      logger.warning("ssh_public_key_path is not specified in config, "
-                     "only project-wide key will be effective.")
+        # Add per-instance ssh key
+        if self._ssh_public_key_path:
+            rsa = self._LoadSshPublicKey(self._ssh_public_key_path)
+            logger.info(
+                "ssh_public_key_path is specified in config: %s, "
+                "will add the key to the instance.", self._ssh_public_key_path)
+            metadata["sshKeys"] = "%s:%s" % (getpass.getuser(), rsa)
+        else:
+            logger.warning("ssh_public_key_path is not specified in config, "
+                           "only project-wide key will be effective.")
 
-    gcompute_client.ComputeClient.CreateInstance(
-        self,
-        instance=instance,
-        image_name=image_name,
-        image_project=image_project,
-        disk_args=disk_args,
-        metadata=metadata,
-        machine_type=self._machine_type,
-        network=self._network,
-        zone=self._zone,
-        gpu=gpu)
+        gcompute_client.ComputeClient.CreateInstance(
+            self,
+            instance=instance,
+            image_name=image_name,
+            image_project=image_project,
+            disk_args=disk_args,
+            metadata=metadata,
+            machine_type=self._machine_type,
+            network=self._network,
+            zone=self._zone,
+            gpu=gpu)
diff --git a/internal/lib/goldfish_compute_client_test.py b/internal/lib/goldfish_compute_client_test.py
index 8e116d2..461fa48 100644
--- a/internal/lib/goldfish_compute_client_test.py
+++ b/internal/lib/goldfish_compute_client_test.py
@@ -13,117 +13,121 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-
 """Tests for acloud.internal.lib.goldfish_compute_client."""
+import unittest
 import mock
 
-import unittest
 from acloud.internal.lib import driver_test_lib
 from acloud.internal.lib import gcompute_client
 from acloud.internal.lib import goldfish_compute_client
 
 
 class GoldfishComputeClientTest(driver_test_lib.BaseDriverTest):
-  """Test GoldfishComputeClient."""
+    """Test GoldfishComputeClient."""
 
-  SSH_PUBLIC_KEY_PATH = ""
-  INSTANCE = "fake-instance"
-  IMAGE = "fake-image"
-  IMAGE_PROJECT = "fake-iamge-project"
-  MACHINE_TYPE = "fake-machine-type"
-  NETWORK = "fake-network"
-  ZONE = "fake-zone"
-  BRANCH = "fake-branch"
-  TARGET = "sdk_phone_x86_64-sdk"
-  BUILD_ID = "2263051"
-  EMULATOR_BRANCH = "aosp-emu-master-dev"
-  EMULATOR_BUILD_ID = "1234567"
-  DPI = 160
-  X_RES = 720
-  Y_RES = 1280
-  METADATA = {"metadata_key": "metadata_value"}
-  EXTRA_DATA_DISK_SIZE_GB = 4
-  BOOT_DISK_SIZE_GB = 10
-  GPU = "nvidia-tesla-k80"
+    SSH_PUBLIC_KEY_PATH = ""
+    INSTANCE = "fake-instance"
+    IMAGE = "fake-image"
+    IMAGE_PROJECT = "fake-iamge-project"
+    MACHINE_TYPE = "fake-machine-type"
+    NETWORK = "fake-network"
+    ZONE = "fake-zone"
+    BRANCH = "fake-branch"
+    TARGET = "sdk_phone_x86_64-sdk"
+    BUILD_ID = "2263051"
+    EMULATOR_BRANCH = "aosp-emu-master-dev"
+    EMULATOR_BUILD_ID = "1234567"
+    DPI = 160
+    X_RES = 720
+    Y_RES = 1280
+    METADATA = {"metadata_key": "metadata_value"}
+    EXTRA_DATA_DISK_SIZE_GB = 4
+    BOOT_DISK_SIZE_GB = 10
+    GPU = "nvidia-tesla-k80"
 
-  def _GetFakeConfig(self):
-    """Create a fake configuration object.
+    def _GetFakeConfig(self):
+        """Create a fake configuration object.
 
-    Returns:
-      A fake configuration mock object.
-    """
-    fake_cfg = mock.MagicMock()
-    fake_cfg.ssh_public_key_path = self.SSH_PUBLIC_KEY_PATH
-    fake_cfg.machine_type = self.MACHINE_TYPE
-    fake_cfg.network = self.NETWORK
-    fake_cfg.zone = self.ZONE
-    fake_cfg.resolution = "{x}x{y}x32x{dpi}".format(
-        x=self.X_RES, y=self.Y_RES, dpi=self.DPI)
-    fake_cfg.metadata_variable = self.METADATA
-    fake_cfg.extra_data_disk_size_gb = self.EXTRA_DATA_DISK_SIZE_GB
-    return fake_cfg
+        Returns:
+            A fake configuration mock object.
+        """
+        fake_cfg = mock.MagicMock()
+        fake_cfg.ssh_public_key_path = self.SSH_PUBLIC_KEY_PATH
+        fake_cfg.machine_type = self.MACHINE_TYPE
+        fake_cfg.network = self.NETWORK
+        fake_cfg.zone = self.ZONE
+        fake_cfg.resolution = "{x}x{y}x32x{dpi}".format(
+            x=self.X_RES, y=self.Y_RES, dpi=self.DPI)
+        fake_cfg.metadata_variable = self.METADATA
+        fake_cfg.extra_data_disk_size_gb = self.EXTRA_DATA_DISK_SIZE_GB
+        return fake_cfg
 
-  def setUp(self):
-    """Set up the test."""
-    super(GoldfishComputeClientTest, self).setUp()
-    self.Patch(goldfish_compute_client.GoldfishComputeClient,
-               "InitResourceHandle")
-    self.goldfish_compute_client = (
-        goldfish_compute_client.GoldfishComputeClient(self._GetFakeConfig(),
-                                                      mock.MagicMock()))
-    self.Patch(
-        gcompute_client.ComputeClient, "CompareMachineSize", return_value=1)
-    self.Patch(
-        gcompute_client.ComputeClient,
-        "GetImage",
-        return_value={"diskSizeGb": 10})
-    self.Patch(gcompute_client.ComputeClient, "CreateInstance")
-    self.Patch(
-        goldfish_compute_client.GoldfishComputeClient,
-        "_GetDiskArgs",
-        return_value=[{
-            "fake_arg": "fake_value"
-        }])
+    def setUp(self):
+        """Set up the test."""
+        super(GoldfishComputeClientTest, self).setUp()
+        self.Patch(goldfish_compute_client.GoldfishComputeClient,
+                   "InitResourceHandle")
+        self.goldfish_compute_client = (
+            goldfish_compute_client.GoldfishComputeClient(
+                self._GetFakeConfig(), mock.MagicMock()))
+        self.Patch(
+            gcompute_client.ComputeClient,
+            "CompareMachineSize",
+            return_value=1)
+        self.Patch(
+            gcompute_client.ComputeClient,
+            "GetImage",
+            return_value={"diskSizeGb": 10})
+        self.Patch(gcompute_client.ComputeClient, "CreateInstance")
+        self.Patch(
+            goldfish_compute_client.GoldfishComputeClient,
+            "_GetDiskArgs",
+            return_value=[{
+                "fake_arg": "fake_value"
+            }])
 
-  def testCreateInstance(self):
-    """Test CreateInstance."""
+    def testCreateInstance(self):
+        """Test CreateInstance."""
 
-    expected_metadata = {
-        "cvd_01_dpi":
+        expected_metadata = {
+            "cvd_01_dpi":
             str(self.DPI),
-        "cvd_01_fetch_android_build_target":
+            "cvd_01_fetch_android_build_target":
             self.TARGET,
-        "cvd_01_fetch_android_bid":
+            "cvd_01_fetch_android_bid":
             "{branch}/{build_id}".format(
                 branch=self.BRANCH, build_id=self.BUILD_ID),
-        "cvd_01_fetch_emulator_bid":
+            "cvd_01_fetch_emulator_bid":
             "{branch}/{build_id}".format(
                 branch=self.EMULATOR_BRANCH, build_id=self.EMULATOR_BUILD_ID),
-        "cvd_01_launch":
+            "cvd_01_launch":
             "1",
-        "cvd_01_x_res":
+            "cvd_01_x_res":
             str(self.X_RES),
-        "cvd_01_y_res":
+            "cvd_01_y_res":
             str(self.Y_RES),
-    }
-    expected_metadata.update(self.METADATA)
-    expected_disk_args = [{"fake_arg": "fake_value"}]
+        }
+        expected_metadata.update(self.METADATA)
+        expected_disk_args = [{"fake_arg": "fake_value"}]
 
-    self.goldfish_compute_client.CreateInstance(
-        self.INSTANCE, self.IMAGE, self.IMAGE_PROJECT, self.TARGET, self.BRANCH,
-        self.BUILD_ID, self.EMULATOR_BRANCH, self.EMULATOR_BUILD_ID,
-        self.EXTRA_DATA_DISK_SIZE_GB, self.GPU)
-    gcompute_client.ComputeClient.CreateInstance.assert_called_with(
-        self.goldfish_compute_client,
-        instance=self.INSTANCE,
-        image_name=self.IMAGE,
-        image_project=self.IMAGE_PROJECT,
-        disk_args=expected_disk_args,
-        metadata=expected_metadata,
-        machine_type=self.MACHINE_TYPE,
-        network=self.NETWORK,
-        zone=self.ZONE,
-        gpu=self.GPU)
+        self.goldfish_compute_client.CreateInstance(
+            self.INSTANCE, self.IMAGE, self.IMAGE_PROJECT, self.TARGET,
+            self.BRANCH, self.BUILD_ID, self.EMULATOR_BRANCH,
+            self.EMULATOR_BUILD_ID, self.EXTRA_DATA_DISK_SIZE_GB, self.GPU)
+
+        # pylint: disable=no-member
+        gcompute_client.ComputeClient.CreateInstance.assert_called_with(
+            self.goldfish_compute_client,
+            instance=self.INSTANCE,
+            image_name=self.IMAGE,
+            image_project=self.IMAGE_PROJECT,
+            disk_args=expected_disk_args,
+            metadata=expected_metadata,
+            machine_type=self.MACHINE_TYPE,
+            network=self.NETWORK,
+            zone=self.ZONE,
+            gpu=self.GPU)
+
 
 if __name__ == "__main__":
-  unittest.main()
+    unittest.main()
diff --git a/internal/lib/utils.py b/internal/lib/utils.py
index 875e183..1c9ac9c 100755
--- a/internal/lib/utils.py
+++ b/internal/lib/utils.py
@@ -13,7 +13,6 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-
 """Common Utilities."""
 
 import base64
@@ -33,10 +32,8 @@
 
 from acloud.public import errors
 
-
 logger = logging.getLogger(__name__)
 
-
 SSH_KEYGEN_CMD = ["ssh-keygen", "-t", "rsa", "-b", "4096"]
 
 
@@ -83,101 +80,112 @@
         except Exception as e:  # pylint: disable=W0703
             if exc_type:
                 logger.error(
-                        "Encountered error while deleting %s: %s",
-                        self.path, str(e), exc_info=True)
+                    "Encountered error while deleting %s: %s",
+                    self.path,
+                    str(e),
+                    exc_info=True)
             else:
                 raise
 
 
-def RetryOnException(retry_checker, max_retries, sleep_multiplier=0,
+def RetryOnException(retry_checker,
+                     max_retries,
+                     sleep_multiplier=0,
                      retry_backoff_factor=1):
-  """Decorater which retries the function call if |retry_checker| returns true.
+    """Decorater which retries the function call if |retry_checker| returns true.
 
-  Args:
-    retry_checker: A callback function which should take an exception instance
-                   and return True if functor(*args, **kwargs) should be retried
-                   when such exception is raised, and return False if it should
-                   not be retried.
-    max_retries: Maximum number of retries allowed.
-    sleep_multiplier: Will sleep sleep_multiplier * attempt_count seconds if
-                      retry_backoff_factor is 1.  Will sleep
-                      sleep_multiplier * (
-                          retry_backoff_factor ** (attempt_count -  1))
-                      if retry_backoff_factor != 1.
-    retry_backoff_factor: See explanation of sleep_multiplier.
+    Args:
+        retry_checker: A callback function which should take an exception instance
+                       and return True if functor(*args, **kwargs) should be retried
+                       when such exception is raised, and return False if it should
+                       not be retried.
+        max_retries: Maximum number of retries allowed.
+        sleep_multiplier: Will sleep sleep_multiplier * attempt_count seconds if
+                          retry_backoff_factor is 1.  Will sleep
+                          sleep_multiplier * (
+                              retry_backoff_factor ** (attempt_count -  1))
+                          if retry_backoff_factor != 1.
+        retry_backoff_factor: See explanation of sleep_multiplier.
 
-  Returns:
-    The function wrapper.
-  """
-  def _Wrapper(func):
-    def _FunctionWrapper(*args, **kwargs):
-      return Retry(retry_checker, max_retries, func, sleep_multiplier,
-                   retry_backoff_factor,
-                   *args, **kwargs)
-    return _FunctionWrapper
-  return _Wrapper
+    Returns:
+        The function wrapper.
+    """
+
+    def _Wrapper(func):
+        def _FunctionWrapper(*args, **kwargs):
+            return Retry(retry_checker, max_retries, func, sleep_multiplier,
+                         retry_backoff_factor, *args, **kwargs)
+
+        return _FunctionWrapper
+
+    return _Wrapper
 
 
-def Retry(retry_checker, max_retries, functor, sleep_multiplier=0,
-          retry_backoff_factor=1, *args, **kwargs):
-  """Conditionally retry a function.
+def Retry(retry_checker,
+          max_retries,
+          functor,
+          sleep_multiplier,
+          retry_backoff_factor,
+          *args,
+          **kwargs):
+    """Conditionally retry a function.
 
-  Args:
-    retry_checker: A callback function which should take an exception instance
-                   and return True if functor(*args, **kwargs) should be retried
-                   when such exception is raised, and return False if it should
-                   not be retried.
-    max_retries: Maximum number of retries allowed.
-    functor: The function to call, will call functor(*args, **kwargs).
-    sleep_multiplier: Will sleep sleep_multiplier * attempt_count seconds if
-                      retry_backoff_factor is 1.  Will sleep
-                      sleep_multiplier * (
-                          retry_backoff_factor ** (attempt_count -  1))
-                      if retry_backoff_factor != 1.
-    retry_backoff_factor: See explanation of sleep_multiplier.
-    *args: Arguments to pass to the functor.
-    **kwargs: Key-val based arguments to pass to the functor.
+    Args:
+        retry_checker: A callback function which should take an exception instance
+                       and return True if functor(*args, **kwargs) should be retried
+                       when such exception is raised, and return False if it should
+                       not be retried.
+        max_retries: Maximum number of retries allowed.
+        functor: The function to call, will call functor(*args, **kwargs).
+        sleep_multiplier: Will sleep sleep_multiplier * attempt_count seconds if
+                          retry_backoff_factor is 1.  Will sleep
+                          sleep_multiplier * (
+                              retry_backoff_factor ** (attempt_count -  1))
+                          if retry_backoff_factor != 1.
+        retry_backoff_factor: See explanation of sleep_multiplier.
+        *args: Arguments to pass to the functor.
+        **kwargs: Key-val based arguments to pass to the functor.
 
-  Returns:
-    The return value of the functor.
+    Returns:
+        The return value of the functor.
 
-  Raises:
-    Exception: The exception that functor(*args, **kwargs) throws.
-  """
-  attempt_count = 0
-  while attempt_count <= max_retries:
-    try:
-      attempt_count += 1
-      return_value = functor(*args, **kwargs)
-      return return_value
-    except Exception as e:  # pylint: disable=W0703
-      if retry_checker(e) and attempt_count <= max_retries:
-        if retry_backoff_factor != 1:
-          sleep = sleep_multiplier * (
-              retry_backoff_factor ** (attempt_count -  1))
-        else:
-          sleep = sleep_multiplier * attempt_count
-        time.sleep(sleep)
-      else:
-        raise
+    Raises:
+        Exception: The exception that functor(*args, **kwargs) throws.
+    """
+    attempt_count = 0
+    while attempt_count <= max_retries:
+        try:
+            attempt_count += 1
+            return_value = functor(*args, **kwargs)
+            return return_value
+        except Exception as e:  # pylint: disable=W0703
+            if retry_checker(e) and attempt_count <= max_retries:
+                if retry_backoff_factor != 1:
+                    sleep = sleep_multiplier * (retry_backoff_factor**
+                                                (attempt_count - 1))
+                else:
+                    sleep = sleep_multiplier * attempt_count
+                    time.sleep(sleep)
+            else:
+                raise
 
 
 def RetryExceptionType(exception_types, max_retries, functor, *args, **kwargs):
-  """Retry exception if it is one of the given types.
+    """Retry exception if it is one of the given types.
 
-  Args:
-    exception_types: A tuple of exception types, e.g. (ValueError, KeyError)
-    max_retries: Max number of retries allowed.
-    functor: The function to call. Will be retried if exception is raised and
-             the exception is one of the exception_types.
-    *args: Arguments to pass to Retry function.
-    **kwargs: Key-val based arguments to pass to Retry functions.
+    Args:
+        exception_types: A tuple of exception types, e.g. (ValueError, KeyError)
+        max_retries: Max number of retries allowed.
+        functor: The function to call. Will be retried if exception is raised and
+                 the exception is one of the exception_types.
+        *args: Arguments to pass to Retry function.
+        **kwargs: Key-val based arguments to pass to Retry functions.
 
-  Returns:
-    The value returned by calling functor.
-  """
-  return Retry(lambda e: isinstance(e, exception_types), max_retries,
-               functor, *args, **kwargs)
+    Returns:
+        The value returned by calling functor.
+    """
+    return Retry(lambda e: isinstance(e, exception_types), max_retries,
+                 functor, *args, **kwargs)
 
 
 def PollAndWait(func, expected_return, timeout_exception, timeout_secs,
@@ -261,27 +269,27 @@
     """
     public_key_path = os.path.expanduser(public_key_path)
     private_key_path = os.path.expanduser(private_key_path)
-    create_key = (
-            not os.path.exists(public_key_path) and
-            not os.path.exists(private_key_path))
+    create_key = (not os.path.exists(public_key_path)
+                  and not os.path.exists(private_key_path))
     if not create_key:
-        logger.debug("The ssh private key (%s) or public key (%s) already exist,"
-                     "will not automatically create the key pairs.",
-                     private_key_path, public_key_path)
+        logger.debug(
+            "The ssh private key (%s) or public key (%s) already exist,"
+            "will not automatically create the key pairs.", private_key_path,
+            public_key_path)
         return
     cmd = SSH_KEYGEN_CMD + ["-C", getpass.getuser(), "-f", private_key_path]
-    logger.info("The ssh private key (%s) and public key (%s) do not exist, "
-                "automatically creating key pair, calling: %s",
-                private_key_path, public_key_path, " ".join(cmd))
+    logger.info(
+        "The ssh private key (%s) and public key (%s) do not exist, "
+        "automatically creating key pair, calling: %s", private_key_path,
+        public_key_path, " ".join(cmd))
     try:
         subprocess.check_call(cmd, stdout=sys.stderr, stderr=sys.stdout)
     except subprocess.CalledProcessError as e:
-        raise errors.DriverError(
-                "Failed to create ssh key pair: %s" % str(e))
+        raise errors.DriverError("Failed to create ssh key pair: %s" % str(e))
     except OSError as e:
         raise errors.DriverError(
-                "Failed to create ssh key pair, please make sure "
-                "'ssh-keygen' is installed: %s" % str(e))
+            "Failed to create ssh key pair, please make sure "
+            "'ssh-keygen' is installed: %s" % str(e))
 
     # By default ssh-keygen will create a public key file
     # by append .pub to the private key file name. Rename it
@@ -292,8 +300,8 @@
             os.rename(default_pub_key_path, public_key_path)
     except OSError as e:
         raise errors.DriverError(
-                "Failed to rename %s to %s: %s" %
-                (default_pub_key_path, public_key_path, str(e)))
+            "Failed to rename %s to %s: %s" % (default_pub_key_path,
+                                               public_key_path, str(e)))
 
     logger.info("Created ssh private key (%s) and public key (%s)",
                 private_key_path, public_key_path)
@@ -332,8 +340,8 @@
         if binary_data[int_length:int_length + type_length] != key_type:
             raise errors.DriverError("rsa key is invalid: %s" % rsa)
     except (struct.error, binascii.Error) as e:
-        raise errors.DriverError("rsa key is invalid: %s, error: %s" %
-                                 (rsa, str(e)))
+        raise errors.DriverError(
+            "rsa key is invalid: %s, error: %s" % (rsa, str(e)))
 
 
 class BatchHttpRequestExecutor(object):
@@ -385,8 +393,8 @@
         if isinstance(exception, self._other_retriable_errors):
             return True
 
-        if (isinstance(exception, errors.HttpError) and
-                exception.code in self._retry_http_codes):
+        if (isinstance(exception, errors.HttpError)
+                and exception.code in self._retry_http_codes):
             return True
         return False
 
@@ -410,14 +418,15 @@
             # If there is still retriable requests pending, raise an error
             # so that Retry will retry this function with pending_requests.
             raise errors.HasRetriableRequestsError(
-                "Retriable errors: %s" % [str(results[rid][1])
-                                          for rid in self._pending_requests])
+                "Retriable errors: %s" %
+                [str(results[rid][1]) for rid in self._pending_requests])
 
     def Execute(self):
         """Executes the requests and retry if necessary.
 
         Will populate self._final_results.
         """
+
         def _ShouldRetryHandler(exc):
             """Check if |exc| is a retriable exception.
 
@@ -436,7 +445,8 @@
         try:
             self._pending_requests = self._requests.copy()
             Retry(
-                _ShouldRetryHandler, max_retries=self._max_retry,
+                _ShouldRetryHandler,
+                max_retries=self._max_retry,
                 functor=self._ExecuteOnce,
                 sleep_multiplier=self._sleep,
                 retry_backoff_factor=self._backoff_factor)
diff --git a/internal/lib/utils_test.py b/internal/lib/utils_test.py
index a450933..a5e845c 100644
--- a/internal/lib/utils_test.py
+++ b/internal/lib/utils_test.py
@@ -13,7 +13,6 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-
 """Tests for acloud.internal.lib.utils."""
 
 import errno
@@ -24,163 +23,190 @@
 import tempfile
 import time
 
+import unittest
 import mock
 
-import unittest
 from acloud.internal.lib import driver_test_lib
 from acloud.internal.lib import utils
 
 
 class UtilsTest(driver_test_lib.BaseDriverTest):
+    """Test Utils."""
 
-  def testTempDir_Success(self):
-    """Test create a temp dir."""
-    self.Patch(os, "chmod")
-    self.Patch(tempfile, "mkdtemp", return_value="/tmp/tempdir")
-    self.Patch(shutil, "rmtree")
-    with utils.TempDir():
-      pass
-    # Verify.
-    tempfile.mkdtemp.assert_called_once()
-    shutil.rmtree.assert_called_with("/tmp/tempdir")
+    def TestTempDirSuccess(self):
+        """Test create a temp dir."""
+        self.Patch(os, "chmod")
+        self.Patch(tempfile, "mkdtemp", return_value="/tmp/tempdir")
+        self.Patch(shutil, "rmtree")
+        with utils.TempDir():
+            pass
+        # Verify.
+        tempfile.mkdtemp.assert_called_once()  # pylint: disable=no-member
+        shutil.rmtree.assert_called_with("/tmp/tempdir")  # pylint: disable=no-member
 
-  def testTempDir_ExceptionRaised(self):
-    """Test create a temp dir and exception is raised within with-clause."""
-    self.Patch(os, "chmod")
-    self.Patch(tempfile, "mkdtemp", return_value="/tmp/tempdir")
-    self.Patch(shutil, "rmtree")
+    def TestTempDirExceptionRaised(self):
+        """Test create a temp dir and exception is raised within with-clause."""
+        self.Patch(os, "chmod")
+        self.Patch(tempfile, "mkdtemp", return_value="/tmp/tempdir")
+        self.Patch(shutil, "rmtree")
 
-    class ExpectedException(Exception):
-      pass
+        class ExpectedException(Exception):
+            """Expected exception."""
+            pass
 
-    def _Call():
-      with utils.TempDir():
-        raise ExpectedException("Expected exception.")
-    # Verify. ExpectedException should be raised.
-    self.assertRaises(ExpectedException, _Call)
-    tempfile.mkdtemp.assert_called_once()
-    shutil.rmtree.assert_called_with("/tmp/tempdir")
+        def _Call():
+            with utils.TempDir():
+                raise ExpectedException("Expected exception.")
 
-  def testTempDir_WhenDeleteTempDirNoLongerExist(self):
-    """Test create a temp dir and dir no longer exists during deletion."""
-    self.Patch(os, "chmod")
-    self.Patch(tempfile, "mkdtemp", return_value="/tmp/tempdir")
-    expected_error = EnvironmentError()
-    expected_error.errno = errno.ENOENT
-    self.Patch(shutil, "rmtree", side_effect=expected_error)
-    def _Call():
-      with utils.TempDir():
-        pass
-    # Verify no exception should be raised when rmtree raises
-    # EnvironmentError with errno.ENOENT, i.e.
-    # directory no longer exists.
-    _Call()
-    tempfile.mkdtemp.assert_called_once()
-    shutil.rmtree.assert_called_with("/tmp/tempdir")
+        # Verify. ExpectedException should be raised.
+        self.assertRaises(ExpectedException, _Call)
+        tempfile.mkdtemp.assert_called_once()  # pylint: disable=no-member
+        shutil.rmtree.assert_called_with("/tmp/tempdir")  #pylint: disable=no-member
 
-  def testTempDir_WhenDeleteEncounterError(self):
-    """Test create a temp dir and encoutered error during deletion."""
-    self.Patch(os, "chmod")
-    self.Patch(tempfile, "mkdtemp", return_value="/tmp/tempdir")
-    expected_error = OSError("Expected OS Error")
-    self.Patch(shutil, "rmtree", side_effect=expected_error)
-    def _Call():
-      with utils.TempDir():
-        pass
+    def testTempDirWhenDeleteTempDirNoLongerExist(self):  # pylint: disable=invalid-name
+        """Test create a temp dir and dir no longer exists during deletion."""
+        self.Patch(os, "chmod")
+        self.Patch(tempfile, "mkdtemp", return_value="/tmp/tempdir")
+        expected_error = EnvironmentError()
+        expected_error.errno = errno.ENOENT
+        self.Patch(shutil, "rmtree", side_effect=expected_error)
 
-    # Verify OSError should be raised.
-    self.assertRaises(OSError, _Call)
-    tempfile.mkdtemp.assert_called_once()
-    shutil.rmtree.assert_called_with("/tmp/tempdir")
+        def _Call():
+            with utils.TempDir():
+                pass
 
-  def testTempDir_OrininalErrorRaised(self):
-    """Test original error is raised even if tmp dir deletion failed."""
-    self.Patch(os, "chmod")
-    self.Patch(tempfile, "mkdtemp", return_value="/tmp/tempdir")
-    expected_error = OSError("Expected OS Error")
-    self.Patch(shutil, "rmtree", side_effect=expected_error)
+        # Verify no exception should be raised when rmtree raises
+        # EnvironmentError with errno.ENOENT, i.e.
+        # directory no longer exists.
+        _Call()
+        tempfile.mkdtemp.assert_called_once()  #pylint: disable=no-member
+        shutil.rmtree.assert_called_with("/tmp/tempdir")  #pylint: disable=no-member
 
-    class ExpectedException(Exception):
-      pass
+    def testTempDirWhenDeleteEncounterError(self):
+        """Test create a temp dir and encoutered error during deletion."""
+        self.Patch(os, "chmod")
+        self.Patch(tempfile, "mkdtemp", return_value="/tmp/tempdir")
+        expected_error = OSError("Expected OS Error")
+        self.Patch(shutil, "rmtree", side_effect=expected_error)
 
-    def _Call():
-      with utils.TempDir():
-        raise ExpectedException("Expected Exception")
+        def _Call():
+            with utils.TempDir():
+                pass
 
-    # Verify.
-    # ExpectedException should be raised, and OSError
-    # should not be raised.
-    self.assertRaises(ExpectedException, _Call)
-    tempfile.mkdtemp.assert_called_once()
-    shutil.rmtree.assert_called_with("/tmp/tempdir")
+        # Verify OSError should be raised.
+        self.assertRaises(OSError, _Call)
+        tempfile.mkdtemp.assert_called_once()  #pylint: disable=no-member
+        shutil.rmtree.assert_called_with("/tmp/tempdir")  #pylint: disable=no-member
 
-  def testCreateSshKeyPair_KeyAlreadyExists(self):
-    """Test when the key pair already exists."""
-    public_key = "/fake/public_key"
-    private_key = "/fake/private_key"
-    self.Patch(os.path, "exists", side_effect=lambda path: path == public_key)
-    self.Patch(subprocess, "check_call")
-    utils.CreateSshKeyPairIfNotExist(private_key, public_key)
-    self.assertEqual(subprocess.check_call.call_count, 0)
+    def testTempDirOrininalErrorRaised(self):
+        """Test original error is raised even if tmp dir deletion failed."""
+        self.Patch(os, "chmod")
+        self.Patch(tempfile, "mkdtemp", return_value="/tmp/tempdir")
+        expected_error = OSError("Expected OS Error")
+        self.Patch(shutil, "rmtree", side_effect=expected_error)
 
-  def testCreateSshKeyPair_KeyAreCreated(self):
-    """Test when the key pair created."""
-    public_key = "/fake/public_key"
-    private_key = "/fake/private_key"
-    self.Patch(os.path, "exists", return_value=False)
-    self.Patch(subprocess, "check_call")
-    self.Patch(os, "rename")
-    utils.CreateSshKeyPairIfNotExist(private_key, public_key)
-    self.assertEqual(subprocess.check_call.call_count, 1)
-    subprocess.check_call.assert_called_with(
-        utils.SSH_KEYGEN_CMD + ["-C", getpass.getuser(), "-f", private_key],
-        stdout=mock.ANY, stderr=mock.ANY)
+        class ExpectedException(Exception):
+            """Expected exception."""
+            pass
 
-  def testRetryOnException(self):
-    def _IsValueError(exc):
-      return isinstance(exc, ValueError)
-    num_retry = 5
+        def _Call():
+            with utils.TempDir():
+                raise ExpectedException("Expected Exception")
 
-    @utils.RetryOnException(_IsValueError, num_retry)
-    def _RaiseAndRetry(sentinel):
-      sentinel.alert()
-      raise ValueError("Fake error.")
+        # Verify.
+        # ExpectedException should be raised, and OSError
+        # should not be raised.
+        self.assertRaises(ExpectedException, _Call)
+        tempfile.mkdtemp.assert_called_once()  #pylint: disable=no-member
+        shutil.rmtree.assert_called_with("/tmp/tempdir")  #pylint: disable=no-member
 
-    sentinel = mock.MagicMock()
-    self.assertRaises(ValueError, _RaiseAndRetry, sentinel)
-    self.assertEqual(1 + num_retry, sentinel.alert.call_count)
+    def testCreateSshKeyPairKeyAlreadyExists(self):  #pylint: disable=invalid-name
+        """Test when the key pair already exists."""
+        public_key = "/fake/public_key"
+        private_key = "/fake/private_key"
+        self.Patch(
+            os.path, "exists", side_effect=lambda path: path == public_key)
+        self.Patch(subprocess, "check_call")
+        utils.CreateSshKeyPairIfNotExist(private_key, public_key)
+        self.assertEqual(subprocess.check_call.call_count, 0)  #pylint: disable=no-member
 
-  def testRetryExceptionType(self):
-    """Test RetryExceptionType function."""
-    def _RaiseAndRetry(sentinel):
-      sentinel.alert()
-      raise ValueError("Fake error.")
+    def testCreateSshKeyPairKeyAreCreated(self):
+        """Test when the key pair created."""
+        public_key = "/fake/public_key"
+        private_key = "/fake/private_key"
+        self.Patch(os.path, "exists", return_value=False)
+        self.Patch(subprocess, "check_call")
+        self.Patch(os, "rename")
+        utils.CreateSshKeyPairIfNotExist(private_key, public_key)
+        self.assertEqual(subprocess.check_call.call_count, 1)  #pylint: disable=no-member
+        subprocess.check_call.assert_called_with(  #pylint: disable=no-member
+            utils.SSH_KEYGEN_CMD +
+            ["-C", getpass.getuser(), "-f", private_key],
+            stdout=mock.ANY,
+            stderr=mock.ANY)
 
-    num_retry = 5
-    sentinel = mock.MagicMock()
-    self.assertRaises(ValueError, utils.RetryExceptionType,
-                      (KeyError, ValueError), num_retry, _RaiseAndRetry,
-                      sentinel=sentinel)
-    self.assertEqual(1 + num_retry, sentinel.alert.call_count)
+    def TestRetryOnException(self):
+        """Test Retry."""
 
-  def testRetry(self):
-    """Test Retry."""
-    self.Patch(time, "sleep")
-    def _RaiseAndRetry(sentinel):
-      sentinel.alert()
-      raise ValueError("Fake error.")
+        def _IsValueError(exc):
+            return isinstance(exc, ValueError)
 
-    num_retry = 5
-    sentinel = mock.MagicMock()
-    self.assertRaises(ValueError, utils.RetryExceptionType,
-                      (ValueError, KeyError), num_retry, _RaiseAndRetry,
-                      sleep_multiplier=1,
-                      retry_backoff_factor=2,
-                      sentinel=sentinel)
+        num_retry = 5
 
-    self.assertEqual(1 + num_retry, sentinel.alert.call_count)
-    time.sleep.assert_has_calls(
-        [mock.call(1), mock.call(2), mock.call(4), mock.call(8), mock.call(16)])
+        @utils.RetryOnException(_IsValueError, num_retry)
+        def _RaiseAndRetry(sentinel):
+            sentinel.alert()
+            raise ValueError("Fake error.")
+
+        sentinel = mock.MagicMock()
+        self.assertRaises(ValueError, _RaiseAndRetry, sentinel)
+        self.assertEqual(1 + num_retry, sentinel.alert.call_count)
+
+    def testRetryExceptionType(self):
+        """Test RetryExceptionType function."""
+
+        def _RaiseAndRetry(sentinel):
+            sentinel.alert()
+            raise ValueError("Fake error.")
+
+        num_retry = 5
+        sentinel = mock.MagicMock()
+        self.assertRaises(
+            ValueError,
+            utils.RetryExceptionType, (KeyError, ValueError),
+            num_retry,
+            _RaiseAndRetry,
+            sentinel=sentinel)
+        self.assertEqual(1 + num_retry, sentinel.alert.call_count)
+
+    def testRetry(self):
+        """Test Retry."""
+        self.Patch(time, "sleep")
+
+        def _RaiseAndRetry(sentinel):
+            sentinel.alert()
+            raise ValueError("Fake error.")
+
+        num_retry = 5
+        sentinel = mock.MagicMock()
+        self.assertRaises(
+            ValueError,
+            utils.RetryExceptionType, (ValueError, KeyError),
+            num_retry,
+            _RaiseAndRetry,
+            sleep_multiplier=1,
+            retry_backoff_factor=2,
+            sentinel=sentinel)
+
+        self.assertEqual(1 + num_retry, sentinel.alert.call_count)
+        time.sleep.assert_has_calls(  #pylint: disable=no-member
+            [
+                mock.call(1),
+                mock.call(2),
+                mock.call(4),
+                mock.call(8),
+                mock.call(16)
+            ])
 
 
 if __name__ == "__main__":
diff --git a/public/acloud_kernel/acloud_kernel.py b/public/acloud_kernel/acloud_kernel.py
index 39361c4..5fd51b8 100755
--- a/public/acloud_kernel/acloud_kernel.py
+++ b/public/acloud_kernel/acloud_kernel.py
@@ -13,13 +13,11 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-
 """Acloud Kernel Utility.
 
 This CLI implements additional functionality to acloud CLI.
 """
 import argparse
-import os
 import sys
 
 from acloud.public import acloud_common
diff --git a/public/acloud_kernel/kernel_swapper.py b/public/acloud_kernel/kernel_swapper.py
index caf3d9a..35fc744 100755
--- a/public/acloud_kernel/kernel_swapper.py
+++ b/public/acloud_kernel/kernel_swapper.py
@@ -13,12 +13,10 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-
 """Kernel Swapper.
 
 This class manages swapping kernel images for a Cloud Android instance.
 """
-import os
 import subprocess
 
 from acloud.public import errors
@@ -29,9 +27,11 @@
 from acloud.internal.lib import gstorage_client
 from acloud.internal.lib import utils
 
-ALL_SCOPES = ' '.join([android_build_client.AndroidBuildClient.SCOPE,
-                       gstorage_client.StorageClient.SCOPE,
-                       android_compute_client.AndroidComputeClient.SCOPE])
+ALL_SCOPES = ' '.join([
+    android_build_client.AndroidBuildClient.SCOPE,
+    gstorage_client.StorageClient.SCOPE,
+    android_compute_client.AndroidComputeClient.SCOPE
+])
 
 # ssh flags used to communicate with the Cloud Android instance.
 SSH_FLAGS = [
@@ -50,7 +50,7 @@
 
     Attributes:
         _compute_client: AndroidCopmuteClient object, manages AVD.
-        _instance_name: string, name of Cloud Android Instance.
+        _instance_name: tring, name of Cloud Android Instance.
         _target_ip: string, IP address of Cloud Android instance.
         _ssh_flags: string list, flags to be used with ssh and scp.
     """
@@ -83,22 +83,22 @@
         Returns:
             A Report instance.
         """
-        r = report.Report(command='swap_kernel')
+        reboot_image = report.Report(command='swap_kernel')
         try:
             self._ShellCmdOnTarget(MOUNT_CMD)
             self.PushFile(local_kernel_image, '/boot')
             self.RebootTarget()
         except subprocess.CalledProcessError as e:
-            r.AddError(str(e))
-            r.SetStatus(report.Status.FAIL)
-            return r
+            reboot_image.AddError(str(e))
+            reboot_image.SetStatus(report.Status.FAIL)
+            return reboot_image
         except errors.DeviceBootError as e:
-            r.AddError(str(e))
-            r.SetStatus(report.Status.BOOT_FAIL)
-            return r
+            reboot_image.AddError(str(e))
+            reboot_image.SetStatus(report.Status.BOOT_FAIL)
+            return reboot_image
 
-        r.SetStatus(report.Status.SUCCESS)
-        return r
+        reboot_image.SetStatus(report.Status.SUCCESS)
+        return reboot_image
 
     def PushFile(self, src_path, dest_path):
         """Pushes local file to target Cloud Android instance.
@@ -137,7 +137,8 @@
         host_cmd = ' '.join([ssh_cmd, '"%s"' % target_cmd])
         self._ShellCmd(host_cmd)
 
-    def _ShellCmd(self, host_cmd):
+    @staticmethod
+    def _ShellCmd(host_cmd):
         """Runs a shell command on host device.
 
         Args:
@@ -148,7 +149,10 @@
                                            host_cmd.
         """
         utils.Retry(
-            retry_checker=lambda e: isinstance(e, subprocess.CalledProcessError),
+            retry_checker=
+                lambda e: isinstance(e, subprocess.CalledProcessError),
             max_retries=2,
             functor=lambda cmd: subprocess.check_call(cmd, shell=True),
+            sleep_multiplier=0,
+            retry_backoff_factor=1,
             cmd=host_cmd)
diff --git a/public/acloud_kernel/kernel_swapper_test.py b/public/acloud_kernel/kernel_swapper_test.py
index bddb722..dabe4a9 100644
--- a/public/acloud_kernel/kernel_swapper_test.py
+++ b/public/acloud_kernel/kernel_swapper_test.py
@@ -16,15 +16,17 @@
 """Tests acloud.public.acloud_kernel.kernel_swapper."""
 
 import subprocess
-import mock
 
 import unittest
+import mock
+
 from acloud.internal.lib import android_compute_client
 from acloud.internal.lib import auth
 from acloud.internal.lib import driver_test_lib
 from acloud.public.acloud_kernel import kernel_swapper
 
 
+#pylint: disable=too-many-instance-attributes
 class KernelSwapperTest(driver_test_lib.BaseDriverTest):
     """Test kernel_swapper."""
 
@@ -47,16 +49,18 @@
 
         self.kswapper = kernel_swapper.KernelSwapper(self.cfg,
                                                      self.fake_instance)
-        self.ssh_cmd_prefix = 'ssh %s root@%s' % (
-            ' '.join(kernel_swapper.SSH_FLAGS), self.fake_ip)
+        self.ssh_cmd_prefix = 'ssh %s root@%s' % (' '.join(
+            kernel_swapper.SSH_FLAGS), self.fake_ip)
         self.scp_cmd_prefix = 'scp %s' % ' '.join(kernel_swapper.SSH_FLAGS)
 
     def testPushFile(self):
         """Test RebootTarget."""
         fake_src_path = 'fake-src'
         fake_dest_path = 'fake-dest'
-        scp_cmd = ' '.join([self.scp_cmd_prefix, '%s root@%s:%s' %
-                            (fake_src_path, self.fake_ip, fake_dest_path)])
+        scp_cmd = ' '.join([
+            self.scp_cmd_prefix,
+            '%s root@%s:%s' % (fake_src_path, self.fake_ip, fake_dest_path)
+        ])
 
         self.kswapper.PushFile(fake_src_path, fake_dest_path)
         self.subprocess_call.assert_called_once_with(scp_cmd, shell=True)
@@ -64,9 +68,9 @@
     def testRebootTarget(self):
         """Test RebootTarget."""
         self.kswapper.RebootTarget()
-        reboot_cmd = ' '.join([
-            self.ssh_cmd_prefix, '"%s"' % kernel_swapper.REBOOT_CMD
-        ])
+        reboot_cmd = ' '.join(
+            [self.ssh_cmd_prefix,
+             '"%s"' % kernel_swapper.REBOOT_CMD])
 
         self.subprocess_call.assert_called_once_with(reboot_cmd, shell=True)
         self.compute_client.WaitForBoot.assert_called_once_with(
@@ -75,21 +79,22 @@
     def testSwapKernel(self):
         """Test SwapKernel."""
         fake_local_kernel_image = 'fake-kernel'
-        mount_cmd = ' '.join([
-            self.ssh_cmd_prefix, '"%s"' % kernel_swapper.MOUNT_CMD
+        mount_cmd = ' '.join(
+            [self.ssh_cmd_prefix,
+             '"%s"' % kernel_swapper.MOUNT_CMD])
+        scp_cmd = ' '.join([
+            self.scp_cmd_prefix,
+            '%s root@%s:%s' % (fake_local_kernel_image, self.fake_ip, '/boot')
         ])
-        scp_cmd = ' '.join([self.scp_cmd_prefix, '%s root@%s:%s' %
-                            (fake_local_kernel_image, self.fake_ip, '/boot')])
-        reboot_cmd = ' '.join([
-            self.ssh_cmd_prefix, '"%s"' % kernel_swapper.REBOOT_CMD
-        ])
+        reboot_cmd = ' '.join(
+            [self.ssh_cmd_prefix,
+             '"%s"' % kernel_swapper.REBOOT_CMD])
 
         self.kswapper.SwapKernel(fake_local_kernel_image)
         self.subprocess_call.assert_has_calls([
-            mock.call(
-                mount_cmd, shell=True), mock.call(
-                    scp_cmd, shell=True), mock.call(
-                        reboot_cmd, shell=True)
+            mock.call(mount_cmd, shell=True),
+            mock.call(scp_cmd, shell=True),
+            mock.call(reboot_cmd, shell=True)
         ])
 
 
diff --git a/pylintrc b/pylintrc
index 67d515e..b7c5763 100644
--- a/pylintrc
+++ b/pylintrc
@@ -15,4 +15,4 @@
 function-rgx=[A-Z_][a-zA-Z0-9]{2,30}$|(__[a-z][a-zA-Z0-9_]+__)$
 
 # Good variable names which should always be accepted, separated by a comma
-good-names=e, f, logger, ip
+good-names=e, f, logger, ip, main