Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / chromite / cros / commands / cros_deploy.py
index 1a159fe..e93cf7b 100644 (file)
@@ -4,13 +4,15 @@
 
 """cros deploy: Deploy the packages onto the target device."""
 
+from __future__ import print_function
+
 import os
 import logging
 import urlparse
 
 from chromite import cros
-from chromite.cbuildbot import portage_utilities
 from chromite.lib import cros_build_lib
+from chromite.lib import portage_util
 from chromite.lib import remote_access
 
 
@@ -58,6 +60,7 @@ For more information of cros build usage:
     self.ssh_private_key = None
     # The installation root of packages.
     self.root = None
+    self.ping = True
 
   @classmethod
   def AddParser(cls, parser):
@@ -95,12 +98,14 @@ For more information of cros build usage:
     parser.add_argument(
         '--private-key', type='path', default=None,
         help='SSH identify file (private key).')
+    parser.add_argument(
+        '--no-ping', dest='ping', action='store_false', default=True,
+        help='Do not ping the device before attempting to connect to it.')
 
   def GetLatestPackage(self, board, pkg):
     """Returns the path to the latest |pkg| for |board|."""
     sysroot = cros_build_lib.GetSysroot(board=board)
-    matches = portage_utilities.FindPackageNameMatches(
-        pkg, board=board)
+    matches = portage_util.FindPackageNameMatches(pkg, board=board)
     if not matches:
       raise ValueError('Package %s is not installed!' % pkg)
 
@@ -123,7 +128,7 @@ For more information of cros build usage:
         logging.error('Cannot strip package %s', pkg)
         raise
 
-    return portage_utilities.GetBinaryPackagePath(
+    return portage_util.GetBinaryPackagePath(
         cpv.category, cpv.package, cpv.version, sysroot=sysroot,
         packages_dir=packages_dir)
 
@@ -239,6 +244,7 @@ For more information of cros build usage:
     self.strip = self.options.strip
     self.clean_binpkg = self.options.clean_binpkg
     self.root = self.options.root
+    self.ping = self.options.ping
     device = self.options.device
     # pylint: disable=E1101
     if urlparse.urlparse(device).scheme == '':
@@ -262,15 +268,15 @@ For more information of cros build usage:
     try:
       with remote_access.ChromiumOSDeviceHandler(
           self.ssh_hostname, port=self.ssh_port, username=self.ssh_username,
-          private_key=self.ssh_private_key,
-          base_dir=self.DEVICE_BASE_DIR) as device:
+          private_key=self.ssh_private_key, base_dir=self.DEVICE_BASE_DIR,
+          ping=self.ping) as device:
         board = cros_build_lib.GetBoard(device_board=device.board,
                                         override_board=self.options.board)
         logging.info('Board is %s', board)
 
         if self.clean_binpkg:
           logging.info('Cleaning outdated binary packages for %s', board)
-          portage_utilities.CleanOutdatedBinaryPackages(board)
+          portage_util.CleanOutdatedBinaryPackages(board)
 
         if not self._IsPathWritable(device, self.root):
           # Only remounts rootfs if the given root is not writable.