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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 | 121 |
122 def ProvisionDevices(options): | 122 def ProvisionDevices(options): |
123 # TODO(jbudorick): Parallelize provisioning of all attached devices after | 123 # TODO(jbudorick): Parallelize provisioning of all attached devices after |
124 # swithcing from AndroidCommands. | 124 # swithcing from AndroidCommands. |
125 if options.device is not None: | 125 if options.device is not None: |
126 devices = [options.device] | 126 devices = [options.device] |
127 else: | 127 else: |
128 devices = android_commands.GetAttachedDevices() | 128 devices = android_commands.GetAttachedDevices() |
129 for device_serial in devices: | 129 for device_serial in devices: |
130 device = device_utils.DeviceUtils(device_serial) | 130 device = device_utils.DeviceUtils(device_serial) |
131 device.old_interface.EnableAdbRoot() | |
132 WipeDeviceData(device) | |
133 try: | |
134 device_utils.DeviceUtils.parallel(devices).old_interface.Reboot(True) | |
135 except errors.DeviceUnresponsiveError: | |
136 pass | |
137 for device_serial in devices: | |
138 device = device_utils.DeviceUtils(device_serial) | |
139 device.WaitUntilFullyBooted(timeout=90) | 131 device.WaitUntilFullyBooted(timeout=90) |
140 device.old_interface.EnableAdbRoot() | 132 device.old_interface.EnableAdbRoot() |
141 _ConfigureLocalProperties(device) | 133 _ConfigureLocalProperties(device) |
142 device_settings.ConfigureContentSettingsDict( | 134 device_settings.ConfigureContentSettingsDict( |
143 device, device_settings.DETERMINISTIC_DEVICE_SETTINGS) | 135 device, device_settings.DETERMINISTIC_DEVICE_SETTINGS) |
144 # TODO(tonyg): We eventually want network on. However, currently radios | 136 # TODO(tonyg): We eventually want network on. However, currently radios |
145 # can cause perfbots to drain faster than they charge. | 137 # can cause perfbots to drain faster than they charge. |
146 if 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower(): | 138 if 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower(): |
147 device_settings.ConfigureContentSettingsDict( | 139 device_settings.ConfigureContentSettingsDict( |
148 device, device_settings.NETWORK_DISABLED_SETTINGS) | 140 device, device_settings.NETWORK_DISABLED_SETTINGS) |
149 device.old_interface.RunShellCommandWithSU('date -u %f' % time.time()) | 141 device.old_interface.RunShellCommandWithSU('date -u %f' % time.time()) |
150 try: | 142 try: |
151 device_utils.DeviceUtils.parallel(devices).old_interface.Reboot(True) | 143 device_utils.DeviceUtils.parallel(devices).old_interface.Reboot(True) |
152 except errors.DeviceUnresponsiveError: | 144 except errors.DeviceUnresponsiveError: |
153 pass | 145 pass |
154 for device_serial in devices: | 146 for device_serial in devices: |
155 device = device_utils.DeviceUtils(device_serial) | 147 device = device_utils.DeviceUtils(device_serial) |
156 device.WaitUntilFullyBooted(timeout=90) | 148 device.WaitUntilFullyBooted(timeout=90) |
157 (_, props) = device.old_interface.GetShellCommandStatusAndOutput('getprop') | 149 (_, props) = device.old_interface.GetShellCommandStatusAndOutput('getprop') |
158 for prop in props: | 150 for prop in props: |
159 print prop | 151 print prop |
160 if options.auto_reconnect: | 152 if options.auto_reconnect: |
161 PushAndLaunchAdbReboot(devices, options.target) | 153 PushAndLaunchAdbReboot(devices, options.target) |
162 | 154 |
163 | 155 |
164 def main(argv): | 156 def main(argv): |
165 logging.basicConfig(level=logging.INFO) | 157 logging.basicConfig(level=logging.INFO) |
166 | 158 |
167 parser = optparse.OptionParser() | 159 parser = optparse.OptionParser() |
168 parser.add_option('-w', '--wipe', action='store_true', | 160 parser.add_option('--skip-wipe', action='store_true', default=False, |
jbudorick
2014/06/12 00:17:17
Do any of the bots use -w or --wipe?
navabi
2014/06/12 00:34:50
No, there shouldn't be. If you look below that was
| |
169 help='Wipe device data from all attached devices.') | 161 help='Don\'t wipe device data during provisioning.') |
dnj
2014/06/12 00:35:46
Just use quotes here; no need to add unnecessary e
navabi
2014/06/12 01:08:59
Done.
| |
170 parser.add_option('-d', '--device', | 162 parser.add_option('-d', '--device', |
171 help='The serial number of the device to be provisioned') | 163 help='The serial number of the device to be provisioned') |
172 parser.add_option('-t', '--target', default='Debug', help='The build target') | 164 parser.add_option('-t', '--target', default='Debug', help='The build target') |
173 parser.add_option( | 165 parser.add_option( |
174 '-r', '--auto-reconnect', action='store_true', | 166 '-r', '--auto-reconnect', action='store_true', |
175 help='Push binary which will reboot the device on adb disconnections.') | 167 help='Push binary which will reboot the device on adb disconnections.') |
176 options, args = parser.parse_args(argv[1:]) | 168 options, args = parser.parse_args(argv[1:]) |
177 constants.SetBuildType(options.target) | 169 constants.SetBuildType(options.target) |
178 | 170 |
179 if args: | 171 if args: |
180 print >> sys.stderr, 'Unused args %s' % args | 172 print >> sys.stderr, 'Unused args %s' % args |
181 return 1 | 173 return 1 |
182 | 174 |
183 if options.wipe: | 175 if not options.skip_wipe: |
184 devices = android_commands.GetAttachedDevices() | 176 devices = android_commands.GetAttachedDevices() |
dnj
2014/06/12 00:35:46
The old method had an explicit 'wipe' command that
navabi
2014/06/12 01:08:59
Done.
Good catch. The wipe without provisioning s
| |
185 for device_serial in devices: | 177 for device_serial in devices: |
186 device = device_utils.DeviceUtils(device_serial) | 178 device = device_utils.DeviceUtils(device_serial) |
179 device.old_interface.EnableAdbRoot() | |
187 WipeDeviceData(device) | 180 WipeDeviceData(device) |
188 try: | 181 try: |
189 (device_utils.DeviceUtils.parallel(devices) | 182 device_utils.DeviceUtils.parallel(devices).old_interface.Reboot(True) |
dnj
2014/06/12 00:35:46
You should block w/ 'pFinish' like the previous co
jbudorick
2014/06/12 00:51:30
The call to pFinish is vestigial. The call to Rebo
navabi
2014/06/12 01:08:59
Leaving as is.
| |
190 .old_interface.Reboot(True).pFinish(None)) | |
191 except errors.DeviceUnresponsiveError: | 183 except errors.DeviceUnresponsiveError: |
192 pass | 184 pass |
193 else: | 185 for device_serial in devices: |
194 ProvisionDevices(options) | 186 device.WaitUntilFullyBooted(timeout=90) |
dnj
2014/06/12 00:35:46
This 'WaitUntilFullyBooted' will be called twice i
navabi
2014/06/12 01:08:59
Done. It's not expensive, but I removed the one in
| |
187 | |
188 ProvisionDevices(options) | |
195 | 189 |
196 | 190 |
197 if __name__ == '__main__': | 191 if __name__ == '__main__': |
198 sys.exit(main(sys.argv)) | 192 sys.exit(main(sys.argv)) |
OLD | NEW |