Index: build/android/provision_devices.py |
diff --git a/build/android/provision_devices.py b/build/android/provision_devices.py |
index 6ca53b1ccb9605aea82f95e081b5825bacd24e9d..aaf8766a617274d3fe169c9e44b6561e4111d36e 100755 |
--- a/build/android/provision_devices.py |
+++ b/build/android/provision_devices.py |
@@ -21,30 +21,6 @@ from pylib import android_commands |
from pylib import constants |
-def PushAndLaunchAdbReboot(device, target): |
- """Pushes and launches the adb_reboot binary on the device. |
- |
- Arguments: |
- device: The serial number of the device to which the |
- adb_reboot binary should be pushed. |
- target: The build target (example, Debug or Release) which helps in |
- locating the adb_reboot binary. |
- """ |
- print 'Will push and launch adb_reboot on %s' % device |
- android_cmd = android_commands.AndroidCommands(device) |
- # Kill if adb_reboot is already running. |
- android_cmd.KillAllBlocking('adb_reboot', 2) |
- # Push adb_reboot |
- print ' Pushing adb_reboot ...' |
- adb_reboot = os.path.join(constants.CHROME_DIR, |
- 'out/%s/adb_reboot' % target) |
- android_cmd.PushIfNeeded(adb_reboot, '/data/local/') |
- # Launch adb_reboot |
- print ' Launching adb_reboot ...' |
- p = subprocess.Popen(['adb', '-s', device, 'shell'], stdin=subprocess.PIPE) |
- p.communicate('/data/local/adb_reboot; exit\n') |
- |
- |
def LaunchHostHeartbeat(): |
ps = subprocess.Popen(['ps', 'aux'], stdout = subprocess.PIPE) |
stdout, _ = ps.communicate() |
@@ -54,11 +30,37 @@ def LaunchHostHeartbeat(): |
pid = re.findall('(\d+)', match)[1] |
subprocess.call(['kill', str(pid)]) |
# Launch a new host_heartbeat |
- print 'Spawing host heartbeat...' |
+ print 'Spawning host heartbeat...' |
subprocess.Popen([os.path.join(constants.CHROME_DIR, |
'build/android/host_heartbeat.py')]) |
+def PushAndLaunchAdbReboot(devices, target): |
+ """Pushes and launches the adb_reboot binary on the device. |
+ |
+ Arguments: |
+ devices: The list of serial numbers of the device to which the |
+ adb_reboot binary should be pushed. |
+ target : The build target (example, Debug or Release) which helps in |
+ locating the adb_reboot binary. |
+ """ |
+ for device in devices: |
+ print 'Will push and launch adb_reboot on %s' % device |
+ android_cmd = android_commands.AndroidCommands(device) |
+ # Kill if adb_reboot is already running. |
+ android_cmd.KillAllBlocking('adb_reboot', 2) |
+ # Push adb_reboot |
+ print ' Pushing adb_reboot ...' |
+ adb_reboot = os.path.join(constants.CHROME_DIR, |
+ 'out/%s/adb_reboot' % target) |
+ android_cmd.PushIfNeeded(adb_reboot, '/data/local/') |
+ # Launch adb_reboot |
+ print ' Launching adb_reboot ...' |
+ p = subprocess.Popen(['adb', '-s', device, 'shell'], stdin=subprocess.PIPE) |
+ p.communicate('/data/local/adb_reboot; exit\n') |
+ LaunchHostHeartbeat() |
+ |
+ |
def ProvisionDevices(options): |
if options.device is not None: |
devices = [options.device] |
@@ -67,27 +69,29 @@ def ProvisionDevices(options): |
for device in devices: |
android_cmd = android_commands.AndroidCommands(device) |
android_cmd.RunShellCommand('su -c date -u %f' % time.time()) |
- PushAndLaunchAdbReboot(device, options.target) |
- LaunchHostHeartbeat() |
+ if options.auto_reconnect: |
+ if options.target: |
Isaac (away)
2013/04/05 05:41:18
I think you can remove this check if we have a def
Siva Chandra
2013/04/05 20:55:31
Done.
|
+ PushAndLaunchAdbReboot(devices, options.target) |
+ else: |
+ print sys.stderr, 'Target to pick the adb_reboot from not specified.' |
+ return 1 |
def main(argv): |
parser = optparse.OptionParser() |
parser.add_option('-d', '--device', |
help='The serial number of the device to be provisioned') |
- parser.add_option('-t', '--target', |
- help='Path to the adb_reboot binary') |
+ parser.add_option('-t', '--target', help='The build target') |
Isaac (away)
2013/04/05 05:41:18
let's default this to 'Debug'
Siva Chandra
2013/04/05 20:55:31
Done.
|
+ parser.add_option( |
+ '-r', '--auto-reconnect', action='store_true', |
+ help='Specify that the adb_reboot binary should be pushed to the devices') |
Isaac (away)
2013/04/05 05:41:18
'Push binary which will reboot the device on adb d
Siva Chandra
2013/04/05 20:55:31
Done.
|
options, args = parser.parse_args(argv[1:]) |
if args: |
print >> sys.stderr, 'Unused args %s' % args |
return 1 |
- if not options.target: |
- print >> sys.stderr, 'Build target not specified' |
- return 1 |
- |
- ProvisionDevices(options) |
+ return ProvisionDevices(options) |
if __name__ == '__main__': |