Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2582)

Unified Diff: build/android/adb_install_apk.py

Issue 1186443002: Revert of [Android] Make adb_install_apk use the device blacklist. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/adb_install_apk.py
diff --git a/build/android/adb_install_apk.py b/build/android/adb_install_apk.py
index 0c6fe8255ebffb0b837ea937bfc8767a1791ff32..00bd38e1821d7957efcc5ffbd0dc9bc027f6fd09 100755
--- a/build/android/adb_install_apk.py
+++ b/build/android/adb_install_apk.py
@@ -6,87 +6,84 @@
"""Utility script to install APKs from the command line quickly."""
-import argparse
-import logging
+import optparse
import os
import sys
from pylib import constants
-from pylib.device import device_blacklist
from pylib.device import device_errors
from pylib.device import device_utils
-from pylib.utils import run_tests_helper
-def main():
- parser = argparse.ArgumentParser()
+def AddInstallAPKOption(option_parser):
+ """Adds apk option used to install the APK to the OptionParser."""
+ option_parser.add_option('--apk',
+ help=('DEPRECATED The name of the apk containing the'
+ ' application (with the .apk extension).'))
+ option_parser.add_option('--apk_package',
+ help=('DEPRECATED The package name used by the apk '
+ 'containing the application.'))
+ option_parser.add_option('--keep_data',
+ action='store_true',
+ default=False,
+ help=('Keep the package data when installing '
+ 'the application.'))
+ option_parser.add_option('--debug', action='store_const', const='Debug',
+ dest='build_type',
+ default=os.environ.get('BUILDTYPE', 'Debug'),
+ help='If set, run test suites under out/Debug. '
+ 'Default is env var BUILDTYPE or Debug')
+ option_parser.add_option('--release', action='store_const', const='Release',
+ dest='build_type',
+ help='If set, run test suites under out/Release. '
+ 'Default is env var BUILDTYPE or Debug.')
+ option_parser.add_option('-d', '--device', dest='device',
+ help='Target device for apk to install on.')
- apk_group = parser.add_mutually_exclusive_group(required=True)
- apk_group.add_argument('--apk', dest='apk_name',
- help='DEPRECATED The name of the apk containing the'
- ' application (with the .apk extension).')
- apk_group.add_argument('apk_path', nargs='?',
- help='The path to the APK to install.')
- # TODO(jbudorick): Remove once no clients pass --apk_package
- parser.add_argument('--apk_package', help='DEPRECATED unused')
- parser.add_argument('--keep_data',
- action='store_true',
- default=False,
- help='Keep the package data when installing '
- 'the application.')
- parser.add_argument('--debug', action='store_const', const='Debug',
- dest='build_type',
- default=os.environ.get('BUILDTYPE', 'Debug'),
- help='If set, run test suites under out/Debug. '
- 'Default is env var BUILDTYPE or Debug')
- parser.add_argument('--release', action='store_const', const='Release',
- dest='build_type',
- help='If set, run test suites under out/Release. '
- 'Default is env var BUILDTYPE or Debug.')
- parser.add_argument('-d', '--device', dest='device',
- help='Target device for apk to install on.')
- parser.add_argument('-v', '--verbose', action='count',
- help='Enable verbose logging.')
+def ValidateInstallAPKOption(option_parser, options, args):
+ """Validates the apk option and potentially qualifies the path."""
+ if not options.apk:
+ if len(args) > 1:
+ options.apk = args[1]
+ else:
+ option_parser.error('apk target not specified.')
- args = parser.parse_args()
+ if not options.apk.endswith('.apk'):
+ options.apk += '.apk'
- run_tests_helper.SetLogLevel(args.verbose)
- constants.SetBuildType(args.build_type)
+ if not os.path.exists(options.apk):
+ options.apk = os.path.join(constants.GetOutDirectory(), 'apks',
+ options.apk)
- if args.apk_path:
- apk = args.apk_path
- else:
- apk = args.apk_name
- if not apk.endswith('.apk'):
- apk += '.apk'
- if not os.path.exists(apk):
- apk = os.path.join(constants.GetOutDirectory(), 'apks', apk)
+
+def main(argv):
+ parser = optparse.OptionParser()
+ parser.set_usage("usage: %prog [options] target")
+ AddInstallAPKOption(parser)
+ options, args = parser.parse_args(argv)
+
+ if len(args) > 1 and options.apk:
+ parser.error("Appending the apk as argument can't be used with --apk.")
+ elif len(args) > 2:
+ parser.error("Too many arguments.")
+
+ constants.SetBuildType(options.build_type)
+ ValidateInstallAPKOption(parser, options, args)
devices = device_utils.DeviceUtils.HealthyDevices()
- if args.device:
- devices = [d for d in devices if d == args.device]
+ if options.device:
+ devices = [d for d in devices if d == options.device]
if not devices:
- raise device_errors.DeviceUnreachableError(args.device)
+ raise device_errors.DeviceUnreachableError(options.device)
elif not devices:
raise device_errors.NoDevicesError()
- def blacklisting_install(device):
- try:
- device.Install(apk, reinstall=args.keep_data)
- except device_errors.CommandFailedError:
- logging.exception('Failed to install %s', args.apk)
- device_blacklist.ExtendBlacklist([str(device)])
- logging.warning('Blacklisting %s', str(device))
- except device_errors.CommandTimeoutError:
- logging.exception('Timed out while installing %s', args.apk)
- device_blacklist.ExtendBlacklist([str(device)])
- logging.warning('Blacklisting %s', str(device))
-
- device_utils.DeviceUtils.parallel(devices).pMap(blacklisting_install)
+ device_utils.DeviceUtils.parallel(devices).Install(
+ options.apk, reinstall=options.keep_data)
if __name__ == '__main__':
- sys.exit(main())
+ sys.exit(main(sys.argv))
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698