Merge "Update create_goldfish_action and error to be pylint compliant."
diff --git a/public/actions/create_goldfish_action.py b/public/actions/create_goldfish_action.py
index 536210c..688440a 100644
--- a/public/actions/create_goldfish_action.py
+++ b/public/actions/create_goldfish_action.py
@@ -13,14 +13,12 @@
 # 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.
-
 """Action to create goldfish device instances.
 
 A Goldfish device is an emulated android device based on the android
 emulator.
 """
 import logging
-import os
 
 from acloud.public.actions import common_operations
 from acloud.public.actions import base_device_factory
@@ -37,62 +35,88 @@
 
 
 class GoldfishDeviceFactory(base_device_factory.BaseDeviceFactory):
-  """A class that can produce a goldfish device."""
+    """A class that can produce a goldfish device.
 
-  def __init__(self,
-               cfg,
-               build_target,
-               build_id,
-               emulator_build_target,
-               emulator_build_id,
-               gpu=None):
-    self.credentials = auth.CreateCredentials(cfg, ALL_SCOPES)
-
-    compute_client = goldfish_compute_client.GoldfishComputeClient(
-        cfg, self.credentials)
-    super(GoldfishDeviceFactory, self).__init__(compute_client)
-
-    # Private creation parameters
-    self._cfg = cfg
-    self._build_target = build_target
-    self._build_id = build_id
-    self._emulator_build_id = emulator_build_id
-    self._emulator_build_target = emulator_build_target
-    self._gpu = gpu
-    self._blank_data_disk_size_gb = cfg.extra_data_disk_size_gb
-
-    # Configure clients
-    self._build_client = android_build_client.AndroidBuildClient(
-        self.credentials)
-
-    # Discover branches
-    self._branch = self._build_client.GetBranch(build_target, build_id)
-    self._emulator_branch = self._build_client.GetBranch(
-        emulator_build_target, emulator_build_id)
-
-  def CreateInstance(self):
-    """Creates singe configured goldfish device.
-
-    Override method from parent class.
-
-    Returns:
-      The name of the created instance.
+    Attributes:
+        _cfg: An AcloudConfig instance.
+        _build_target: String, the build target, e.g. aosp_x86-eng.
+        _build_id: String, Build id, e.g. "2263051", "P2804227"
+        _emulator_build_target: String, the emulator build target, e.g. aosp_x86-eng.
+        _emulator_build_id: String, emulator build id.
+        _gpu: String, GPU to attach to the device or None. e.g. "nvidia-tesla-k80"
+        _blank_data_disk_size_gb: Integer, extra disk size
+        _build_client: An AndroidBuildClient instance
+        _branch: String, android branch name, e.g. git_master
+        _emulator_branch: String, emulator branch name, e.g. "aosp-emu-master-dev"
     """
-    instance = self._compute_client.GenerateInstanceName(self._build_id)
 
-    self._compute_client.CreateInstance(
-        instance=instance,
-        image_name=self._cfg.stable_goldfish_host_image_name,
-        image_project=self._cfg.stable_goldfish_host_image_project,
-        build_target=self._build_target,
-        branch=self._branch,
-        build_id=self._build_id,
-        emulator_branch=self._emulator_branch,
-        emulator_build_id=self._emulator_build_id,
-        gpu=self._gpu,
-        blank_data_disk_size_gb=self._blank_data_disk_size_gb)
+    def __init__(self,
+                 cfg,
+                 build_target,
+                 build_id,
+                 emulator_build_target,
+                 emulator_build_id,
+                 gpu=None):
 
-    return instance
+        """Initialize.
+
+        Args:
+            cfg: An AcloudConfig instance.
+            build_target: String, the build target, e.g. aosp_x86-eng.
+            build_id: String, Build id, e.g. "2263051", "P2804227"
+            emulator_build_target: String, the emulator build target, e.g. aosp_x86-eng.
+            emulator_build_id: String, emulator build id.
+            gpu: String, GPU to attach to the device or None. e.g. "nvidia-tesla-k80"
+        """
+
+        self.credentials = auth.CreateCredentials(cfg, ALL_SCOPES)
+
+        compute_client = goldfish_compute_client.GoldfishComputeClient(
+            cfg, self.credentials)
+        super(GoldfishDeviceFactory, self).__init__(compute_client)
+
+        # Private creation parameters
+        self._cfg = cfg
+        self._build_target = build_target
+        self._build_id = build_id
+        self._emulator_build_id = emulator_build_id
+        self._emulator_build_target = emulator_build_target
+        self._gpu = gpu
+        self._blank_data_disk_size_gb = cfg.extra_data_disk_size_gb
+
+        # Configure clients
+        self._build_client = android_build_client.AndroidBuildClient(
+            self.credentials)
+
+        # Discover branches
+        self._branch = self._build_client.GetBranch(build_target, build_id)
+        self._emulator_branch = self._build_client.GetBranch(
+            emulator_build_target, emulator_build_id)
+
+    def CreateInstance(self):
+        """Creates single configured goldfish device.
+
+        Override method from parent class.
+
+        Returns:
+            String, the name of the created instance.
+        """
+        instance = self._compute_client.GenerateInstanceName(self._build_id)
+
+        self._compute_client.CreateInstance(
+            instance=instance,
+            image_name=self._cfg.stable_goldfish_host_image_name,
+            image_project=self._cfg.stable_goldfish_host_image_project,
+            build_target=self._build_target,
+            branch=self._branch,
+            build_id=self._build_id,
+            emulator_branch=self._emulator_branch,
+            emulator_build_id=self._emulator_build_id,
+            gpu=self._gpu,
+            blank_data_disk_size_gb=self._blank_data_disk_size_gb)
+
+        return instance
+
 
 
 def CreateDevices(cfg,
@@ -104,35 +128,36 @@
                   serial_log_file=None,
                   logcat_file=None,
                   autoconnect=False):
-  """Create one or multiple Goldfish devices.
+    """Create one or multiple Goldfish devices.
 
-  Args:
-    cfg: An AcloudConfig instance.
-    build_target: Target name.
-    build_id: Build id, a string, e.g. "2263051", "P2804227"
-    emulator_build_id: emulator build id, a string.
-    gpu: GPU to attach to the device or None. e.g. "nvidia-tesla-k80"
-    num: Number of devices to create.
-    serial_log_file: A path to a file where serial output should
+    Args:
+        cfg: An AcloudConfig instance.
+        build_target: String, the build target, e.g. aosp_x86-eng.
+        build_id: String, Build id, e.g. "2263051", "P2804227"
+        emulator_build_id: String, emulator build id.
+        gpu: String, GPU to attach to the device or None. e.g. "nvidia-tesla-k80"
+        num: Integer, Number of devices to create.
+        serial_log_file: String, A path to a file where serial output should
                         be saved to.
-    logcat_file: A path to a file where logcat logs should be saved.
-    autoconnect: Create ssh tunnel(s) and adb connect after device creation.
+        logcat_file: String, A path to a file where logcat logs should be saved.
+        autoconnect: Boolean, Create ssh tunnel(s) and adb connect after device creation.
 
-  Returns:
-    A Report instance.
-  """
-  # TODO(fdeng, pinghao): Implement copying files from the instance, including
-  # the serial log (kernel log), and logcat log files.
-  # TODO(fdeng, pinghao): Implement autoconnect.
-  logger.info("Creating a goldfish device in project %s, build_target: %s, "
-              "build_id: %s, emulator_bid: %s, GPU: %s, num: %s, "
-              "serial_log_file: %s, logcat_file: %s, "
-              "autoconnect: %s", cfg.project, build_target, build_id,
-              emulator_build_id, gpu, num, serial_log_file, logcat_file,
-              autoconnect)
+    Returns:
+        A Report instance.
+    """
+    # TODO: Implement copying files from the instance, including
+    # the serial log (kernel log), and logcat log files.
+    # TODO: Implement autoconnect.
+    logger.info(
+        "Creating a goldfish device in project %s, build_target: %s, "
+        "build_id: %s, emulator_bid: %s, GPU: %s, num: %s, "
+        "serial_log_file: %s, logcat_file: %s, "
+        "autoconnect: %s", cfg.project, build_target, build_id,
+        emulator_build_id, gpu, num, serial_log_file, logcat_file, autoconnect)
 
-  device_factory = GoldfishDeviceFactory(cfg, build_target, build_id,
-                                         cfg.emulator_build_target,
-                                         emulator_build_id, gpu)
+    device_factory = GoldfishDeviceFactory(cfg, build_target, build_id,
+                                           cfg.emulator_build_target,
+                                           emulator_build_id, gpu)
 
-  return common_operations.CreateDevices("create_gf", cfg, device_factory, num)
+    return common_operations.CreateDevices("create_gf", cfg, device_factory,
+                                           num)
diff --git a/public/actions/create_goldfish_action_test.py b/public/actions/create_goldfish_action_test.py
index 7885d9c..70474a0 100644
--- a/public/actions/create_goldfish_action_test.py
+++ b/public/actions/create_goldfish_action_test.py
@@ -13,12 +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.
-
 """Tests for acloud.public.actions.create_goldfish_actions."""
 import uuid
-import mock
 
 import unittest
+import mock
 from acloud.internal.lib import android_build_client
 from acloud.internal.lib import android_compute_client
 from acloud.internal.lib import auth
@@ -28,99 +27,101 @@
 
 
 class CreateGoldfishActionTest(driver_test_lib.BaseDriverTest):
-  """Test create_goldfish_action."""
+    """Tests create_goldfish_action."""
 
-  IP = "127.0.0.1"
-  INSTANCE = "fake-instance"
-  IMAGE = "fake-image"
-  BUILD_TARGET = "fake-build-target"
-  EMULATOR_TARGET = "emu-fake-target"
-  BUILD_ID = "12345"
-  EMULATOR_BUILD_ID = "1234567"
-  GPU = "nvidia-tesla-k80"
-  BRANCH = "fake-branch"
-  EMULATOR_BRANCH = "emu-fake-branch"
-  GOLDFISH_HOST_IMAGE_NAME = "fake-stable-host-image-name"
-  GOLDFISH_HOST_IMAGE_PROJECT = "fake-stable-host-image-project"
-  EXTRA_DATA_DISK_GB = 4
+    IP = "127.0.0.1"
+    INSTANCE = "fake-instance"
+    IMAGE = "fake-image"
+    BUILD_TARGET = "fake-build-target"
+    EMULATOR_TARGET = "emu-fake-target"
+    BUILD_ID = "12345"
+    EMULATOR_BUILD_ID = "1234567"
+    GPU = "nvidia-tesla-k80"
+    BRANCH = "fake-branch"
+    EMULATOR_BRANCH = "emu-fake-branch"
+    GOLDFISH_HOST_IMAGE_NAME = "fake-stable-host-image-name"
+    GOLDFISH_HOST_IMAGE_PROJECT = "fake-stable-host-image-project"
+    EXTRA_DATA_DISK_GB = 4
 
-  def setUp(self):
-    """Set up the test."""
-    super(CreateGoldfishActionTest, self).setUp()
-    self.build_client = mock.MagicMock()
-    self.Patch(
-        android_build_client,
-        "AndroidBuildClient",
-        return_value=self.build_client)
-    self.compute_client = mock.MagicMock()
-    self.Patch(
-        goldfish_compute_client,
-        "GoldfishComputeClient",
-        return_value=self.compute_client)
-    self.Patch(
-        android_compute_client,
-        "AndroidComputeClient",
-        return_value=self.compute_client)
-    self.Patch(auth, "CreateCredentials", return_value=mock.MagicMock())
+    def setUp(self):
+        """Sets up the test."""
+        super(CreateGoldfishActionTest, self).setUp()
+        self.build_client = mock.MagicMock()
+        self.Patch(
+            android_build_client,
+            "AndroidBuildClient",
+            return_value=self.build_client)
+        self.compute_client = mock.MagicMock()
+        self.Patch(
+            goldfish_compute_client,
+            "GoldfishComputeClient",
+            return_value=self.compute_client)
+        self.Patch(
+            android_compute_client,
+            "AndroidComputeClient",
+            return_value=self.compute_client)
+        self.Patch(auth, "CreateCredentials", return_value=mock.MagicMock())
 
-  def _CreateCfg(self):
-    """A helper method that creates a mock configuration object."""
-    cfg = mock.MagicMock()
-    cfg.service_account_name = "fake@service.com"
-    cfg.service_account_private_key_path = "/fake/path/to/key"
-    cfg.zone = "fake_zone"
-    cfg.ssh_private_key_path = ""
-    cfg.ssh_public_key_path = ""
-    cfg.stable_goldfish_host_image_name = self.GOLDFISH_HOST_IMAGE_NAME
-    cfg.stable_goldfish_host_image_project = self.GOLDFISH_HOST_IMAGE_PROJECT
-    cfg.emulator_build_target = self.EMULATOR_TARGET
-    cfg.extra_data_disk_size_gb = self.EXTRA_DATA_DISK_GB
-    return cfg
+    def _CreateCfg(self):
+        """A helper method that creates a mock configuration object."""
+        cfg = mock.MagicMock()
+        cfg.service_account_name = "fake@service.com"
+        cfg.service_account_private_key_path = "/fake/path/to/key"
+        cfg.zone = "fake_zone"
+        cfg.ssh_private_key_path = ""
+        cfg.ssh_public_key_path = ""
+        cfg.stable_goldfish_host_image_name = self.GOLDFISH_HOST_IMAGE_NAME
+        cfg.stable_goldfish_host_image_project = self.GOLDFISH_HOST_IMAGE_PROJECT
+        cfg.emulator_build_target = self.EMULATOR_TARGET
+        cfg.extra_data_disk_size_gb = self.EXTRA_DATA_DISK_GB
+        return cfg
 
-  def testCreateDevices(self):
-    """Test CreateDevices."""
-    cfg = self._CreateCfg()
+    def testCreateDevices(self):
+        """Tests CreateDevices."""
+        cfg = self._CreateCfg()
 
-    # Mock uuid
-    fake_uuid = mock.MagicMock(hex="1234")
-    self.Patch(uuid, "uuid4", return_value=fake_uuid)
+        # Mock uuid
+        fake_uuid = mock.MagicMock(hex="1234")
+        self.Patch(uuid, "uuid4", return_value=fake_uuid)
 
-    # Mock compute client methods
-    self.compute_client.GetInstanceIP.return_value = self.IP
-    self.compute_client.GenerateImageName.return_value = self.IMAGE
-    self.compute_client.GenerateInstanceName.return_value = self.INSTANCE
+        # Mock compute client methods
+        self.compute_client.GetInstanceIP.return_value = self.IP
+        self.compute_client.GenerateImageName.return_value = self.IMAGE
+        self.compute_client.GenerateInstanceName.return_value = self.INSTANCE
 
-    # Mock build client method
-    self.build_client.GetBranch.side_effect = [
-        self.BRANCH, self.EMULATOR_BRANCH
-    ]
+        # Mock build client method
+        self.build_client.GetBranch.side_effect = [
+            self.BRANCH, self.EMULATOR_BRANCH
+        ]
 
-    # Call CreateDevices
-    r = create_goldfish_action.CreateDevices(
-        cfg, self.BUILD_TARGET, self.BUILD_ID, self.EMULATOR_BUILD_ID, self.GPU)
+        # Call CreateDevices
+        report = create_goldfish_action.CreateDevices(
+            cfg, self.BUILD_TARGET, self.BUILD_ID, self.EMULATOR_BUILD_ID,
+            self.GPU)
 
-    # Verify
-    self.compute_client.CreateInstance.assert_called_with(
-        instance=self.INSTANCE,
-        blank_data_disk_size_gb=self.EXTRA_DATA_DISK_GB,
-        image_name=self.GOLDFISH_HOST_IMAGE_NAME,
-        image_project=self.GOLDFISH_HOST_IMAGE_PROJECT,
-        build_target=self.BUILD_TARGET,
-        branch=self.BRANCH,
-        build_id=self.BUILD_ID,
-        emulator_branch=self.EMULATOR_BRANCH,
-        emulator_build_id=self.EMULATOR_BUILD_ID,
-        gpu=self.GPU)
+        # Verify
+        self.compute_client.CreateInstance.assert_called_with(
+            instance=self.INSTANCE,
+            blank_data_disk_size_gb=self.EXTRA_DATA_DISK_GB,
+            image_name=self.GOLDFISH_HOST_IMAGE_NAME,
+            image_project=self.GOLDFISH_HOST_IMAGE_PROJECT,
+            build_target=self.BUILD_TARGET,
+            branch=self.BRANCH,
+            build_id=self.BUILD_ID,
+            emulator_branch=self.EMULATOR_BRANCH,
+            emulator_build_id=self.EMULATOR_BUILD_ID,
+            gpu=self.GPU)
 
-    self.assertEquals(r.data, {
-        "devices": [{
-            "instance_name": self.INSTANCE,
-            "ip": self.IP,
-        },],
-    })
-    self.assertEquals(r.command, "create_gf")
-    self.assertEquals(r.status, "SUCCESS")
-
+        self.assertEquals(report.data, {
+            "devices": [
+                {
+                    "instance_name": self.INSTANCE,
+                    "ip": self.IP,
+                },
+            ],
+        })
+        self.assertEquals(report.command, "create_gf")
+        self.assertEquals(report.status, "SUCCESS")
 
 if __name__ == "__main__":
-  unittest.main()
+    unittest.main()
diff --git a/public/errors.py b/public/errors.py
index 0f4c644..64b0c7d 100755
--- a/public/errors.py
+++ b/public/errors.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.
-
 """Define errors that are raised by the driver."""
 
 HTTP_NOT_FOUND_CODE = 404
@@ -79,8 +78,8 @@
 
 
 class DeviceBootError(DriverError):
-  """To catch device boot errors."""
+    """To catch device boot errors."""
 
 
 class DeviceBootTimeoutError(DeviceBootError):
-  """Raised when an AVD defice failed to boot within timeout."""
+    """Raised when an AVD defice failed to boot within timeout."""