OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """Provisions Android devices with settings required for bots. | 7 """Provisions Android devices with settings required for bots. |
8 | 8 |
9 Usage: | 9 Usage: |
10 ./provision_devices.py [-d <device serial number>] | 10 ./provision_devices.py [-d <device serial number>] |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 LaunchHostHeartbeat() | 65 LaunchHostHeartbeat() |
66 | 66 |
67 | 67 |
68 def ProvisionDevices(options): | 68 def ProvisionDevices(options): |
69 if options.device is not None: | 69 if options.device is not None: |
70 devices = [options.device] | 70 devices = [options.device] |
71 else: | 71 else: |
72 devices = android_commands.GetAttachedDevices() | 72 devices = android_commands.GetAttachedDevices() |
73 for device in devices: | 73 for device in devices: |
74 android_cmd = android_commands.AndroidCommands(device) | 74 android_cmd = android_commands.AndroidCommands(device) |
75 android_cmd.RunShellCommand('su -c date -u %f' % time.time()) | 75 android_cmd.RunShellCommandWithSU('date -u %f' % time.time()) |
76 if options.auto_reconnect: | 76 if options.auto_reconnect: |
77 PushAndLaunchAdbReboot(devices, options.target) | 77 PushAndLaunchAdbReboot(devices, options.target) |
78 | 78 |
79 | 79 |
80 def main(argv): | 80 def main(argv): |
81 parser = optparse.OptionParser() | 81 parser = optparse.OptionParser() |
82 parser.add_option('-d', '--device', | 82 parser.add_option('-d', '--device', |
83 help='The serial number of the device to be provisioned') | 83 help='The serial number of the device to be provisioned') |
84 parser.add_option('-t', '--target', default='Debug', help='The build target') | 84 parser.add_option('-t', '--target', default='Debug', help='The build target') |
85 parser.add_option( | 85 parser.add_option( |
86 '-r', '--auto-reconnect', action='store_true', | 86 '-r', '--auto-reconnect', action='store_true', |
87 help='Push binary which will reboot the device on adb disconnections.') | 87 help='Push binary which will reboot the device on adb disconnections.') |
88 options, args = parser.parse_args(argv[1:]) | 88 options, args = parser.parse_args(argv[1:]) |
89 constants.SetBuildType(options.target) | 89 constants.SetBuildType(options.target) |
90 | 90 |
91 if args: | 91 if args: |
92 print >> sys.stderr, 'Unused args %s' % args | 92 print >> sys.stderr, 'Unused args %s' % args |
93 return 1 | 93 return 1 |
94 | 94 |
95 ProvisionDevices(options) | 95 ProvisionDevices(options) |
96 | 96 |
97 | 97 |
98 if __name__ == '__main__': | 98 if __name__ == '__main__': |
99 sys.exit(main(sys.argv)) | 99 sys.exit(main(sys.argv)) |
OLD | NEW |