diff options
author | mlamouri@chromium.org <mlamouri@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-08 20:11:16 +0000 |
---|---|---|
committer | mlamouri@chromium.org <mlamouri@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-08 20:11:16 +0000 |
commit | 068b9cb4de55cf86f151d3921dbb3c62615bb836 (patch) | |
tree | d9ef3f094da79aaf3e577afdfd594818e6d01f7e | |
parent | 9838033635e529074695e63480597a43c2780acd (diff) | |
download | chromium_src-068b9cb4de55cf86f151d3921dbb3c62615bb836.zip chromium_src-068b9cb4de55cf86f151d3921dbb3c62615bb836.tar.gz chromium_src-068b9cb4de55cf86f151d3921dbb3c62615bb836.tar.bz2 |
Make adb_install_apk.py saner for humans.
Scripts like that usually do not require a --option if this is a
mandatory singleton argument. Also, forgetting to pass the extension
sounds like something that the script could simply handle.
BUG=None
Review URL: https://codereview.chromium.org/286423002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275755 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-x | build/android/adb_install_apk.py | 24 | ||||
-rwxr-xr-x | build/android/buildbot/bb_device_steps.py | 3 |
2 files changed, 20 insertions, 7 deletions
diff --git a/build/android/adb_install_apk.py b/build/android/adb_install_apk.py index a915101..7a781ee 100755 --- a/build/android/adb_install_apk.py +++ b/build/android/adb_install_apk.py @@ -19,7 +19,7 @@ from pylib.utils import apk_helper def AddInstallAPKOption(option_parser): """Adds apk option used to install the APK to the OptionParser.""" option_parser.add_option('--apk', - help=('The name of the apk containing the ' + help=('DEPRECATED The name of the apk containing the' ' application (with the .apk extension).')) option_parser.add_option('--apk_package', help=('The package name used by the apk containing ' @@ -40,10 +40,17 @@ def AddInstallAPKOption(option_parser): 'Default is env var BUILDTYPE or Debug.') -def ValidateInstallAPKOption(option_parser, options): +def ValidateInstallAPKOption(option_parser, options, args): """Validates the apk option and potentially qualifies the path.""" if not options.apk: - option_parser.error('--apk is mandatory.') + if len(args) > 1: + options.apk = args[1] + else: + option_parser.error('apk target not specified.') + + if not options.apk.endswith('.apk'): + options.apk += '.apk' + if not os.path.exists(options.apk): options.apk = os.path.join(constants.GetOutDirectory(), 'apks', options.apk) @@ -51,12 +58,17 @@ def ValidateInstallAPKOption(option_parser, options): 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) - if len(args) > 1: - raise Exception('Error: Unknown argument:', args[1:]) + ValidateInstallAPKOption(parser, options, args) devices = android_commands.GetAttachedDevices() if not devices: diff --git a/build/android/buildbot/bb_device_steps.py b/build/android/buildbot/bb_device_steps.py index 3f9b96a..29a4add 100755 --- a/build/android/buildbot/bb_device_steps.py +++ b/build/android/buildbot/bb_device_steps.py @@ -181,9 +181,10 @@ def InstallApk(options, test, print_step=False): if print_step: bb_annotations.PrintNamedStep('install_%s' % test.name.lower()) - args = ['--apk', test.apk, '--apk_package', test.apk_package] + args = ['--apk_package', test.apk_package] if options.target == 'Release': args.append('--release') + args.append(test.apk) RunCmd(['build/android/adb_install_apk.py'] + args, halt_on_failure=True) |