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

Unified Diff: build/android/adb_install_apk.py

Issue 321403002: Add option device in install apk script (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 a91510137925e766cf5166768f78679e7ed51c12..69a36822deadf3dbe454edffe932c6249f56925a 100755
--- a/build/android/adb_install_apk.py
+++ b/build/android/adb_install_apk.py
@@ -38,6 +38,8 @@ def AddInstallAPKOption(option_parser):
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.'))
def ValidateInstallAPKOption(option_parser, options):
@@ -49,6 +51,29 @@ def ValidateInstallAPKOption(option_parser, options):
options.apk)
+def _GetAttachedDevices(device=None):
mlamouri (slow - plz ping) 2014/06/11 09:07:21 I would call the method GetTargetDevices() instead
mlamouri (slow - plz ping) 2014/06/11 09:07:21 It seems that the _Foo() convention isn't used in
+ """Get all attached devices.
+
+ Args:
+ device: Name of a specific device to use.
+
+ Returns:
+ A list of attached devices.
+ """
+ attached_devices = []
+
+ attached_devices = android_commands.GetAttachedDevices()
+ if device:
+ assert device in attached_devices, (
mlamouri (slow - plz ping) 2014/06/11 09:07:21 It seems that we use |raise Exception('Error: ...'
+ 'Did not find device %s among attached device. Attached devices: %s'
+ % (device, ', '.join(attached_devices)))
+ attached_devices = [device]
+
+ assert attached_devices, 'No devices attached.'
+
+ return sorted(attached_devices)
+
+
def main(argv):
parser = optparse.OptionParser()
AddInstallAPKOption(parser)
@@ -58,7 +83,7 @@ def main(argv):
if len(args) > 1:
raise Exception('Error: Unknown argument:', args[1:])
- devices = android_commands.GetAttachedDevices()
+ devices = _GetAttachedDevices(options.device)
jbudorick 2014/06/11 14:32:00 I'd much rather see something like this both here
if not devices:
raise Exception('Error: no connected devices')
« 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