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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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() | 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) | |
140 device.old_interface.EnableAdbRoot() | |
141 _ConfigureLocalProperties(device) | 132 _ConfigureLocalProperties(device) |
142 device_settings.ConfigureContentSettingsDict( | 133 device_settings.ConfigureContentSettingsDict( |
143 device, device_settings.DETERMINISTIC_DEVICE_SETTINGS) | 134 device, device_settings.DETERMINISTIC_DEVICE_SETTINGS) |
144 # TODO(tonyg): We eventually want network on. However, currently radios | 135 # TODO(tonyg): We eventually want network on. However, currently radios |
145 # can cause perfbots to drain faster than they charge. | 136 # can cause perfbots to drain faster than they charge. |
146 if 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower(): | 137 if 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower(): |
147 device_settings.ConfigureContentSettingsDict( | 138 device_settings.ConfigureContentSettingsDict( |
148 device, device_settings.NETWORK_DISABLED_SETTINGS) | 139 device, device_settings.NETWORK_DISABLED_SETTINGS) |
149 device.old_interface.RunShellCommandWithSU('date -u %f' % time.time()) | 140 device.old_interface.RunShellCommandWithSU('date -u %f' % time.time()) |
150 try: | 141 try: |
151 device_utils.DeviceUtils.parallel(devices).old_interface.Reboot(True) | 142 device_utils.DeviceUtils.parallel(devices).old_interface.Reboot(True) |
152 except errors.DeviceUnresponsiveError: | 143 except errors.DeviceUnresponsiveError: |
153 pass | 144 pass |
154 for device_serial in devices: | 145 for device_serial in devices: |
155 device = device_utils.DeviceUtils(device_serial) | 146 device = device_utils.DeviceUtils(device_serial) |
156 device.WaitUntilFullyBooted(timeout=90) | 147 device.WaitUntilFullyBooted(timeout=90) |
157 (_, props) = device.old_interface.GetShellCommandStatusAndOutput('getprop') | 148 (_, props) = device.old_interface.GetShellCommandStatusAndOutput('getprop') |
158 for prop in props: | 149 for prop in props: |
159 print prop | 150 print prop |
160 if options.auto_reconnect: | 151 if options.auto_reconnect: |
161 PushAndLaunchAdbReboot(devices, options.target) | 152 PushAndLaunchAdbReboot(devices, options.target) |
162 | 153 |
163 | 154 |
164 def main(argv): | 155 def main(argv): |
165 logging.basicConfig(level=logging.INFO) | 156 logging.basicConfig(level=logging.INFO) |
166 | 157 |
167 parser = optparse.OptionParser() | 158 parser = optparse.OptionParser() |
168 parser.add_option('-w', '--wipe', action='store_true', | 159 parser.add_option('--skip-wipe', action='store_true', default=False, |
169 help='Wipe device data from all attached devices.') | 160 help="Don't wipe device data during provisioning.") |
170 parser.add_option('-d', '--device', | 161 parser.add_option('-d', '--device', |
171 help='The serial number of the device to be provisioned') | 162 help='The serial number of the device to be provisioned') |
172 parser.add_option('-t', '--target', default='Debug', help='The build target') | 163 parser.add_option('-t', '--target', default='Debug', help='The build target') |
173 parser.add_option( | 164 parser.add_option( |
174 '-r', '--auto-reconnect', action='store_true', | 165 '-r', '--auto-reconnect', action='store_true', |
175 help='Push binary which will reboot the device on adb disconnections.') | 166 help='Push binary which will reboot the device on adb disconnections.') |
176 options, args = parser.parse_args(argv[1:]) | 167 options, args = parser.parse_args(argv[1:]) |
177 constants.SetBuildType(options.target) | 168 constants.SetBuildType(options.target) |
178 | 169 |
179 if args: | 170 if args: |
180 print >> sys.stderr, 'Unused args %s' % args | 171 print >> sys.stderr, 'Unused args %s' % args |
181 return 1 | 172 return 1 |
182 | 173 |
183 if options.wipe: | 174 if not options.skip_wipe: |
184 devices = android_commands.GetAttachedDevices() | 175 if options.device is not None: |
176 devices = [options.device] | |
177 else: | |
178 devices = android_commands.GetAttachedDevices() | |
185 for device_serial in devices: | 179 for device_serial in devices: |
186 device = device_utils.DeviceUtils(device_serial) | 180 device = device_utils.DeviceUtils(device_serial) |
181 device.old_interface.EnableAdbRoot() | |
187 WipeDeviceData(device) | 182 WipeDeviceData(device) |
188 try: | 183 try: |
189 (device_utils.DeviceUtils.parallel(devices) | 184 device_utils.DeviceUtils.parallel(devices).old_interface.Reboot(True) |
190 .old_interface.Reboot(True).pFinish(None)) | |
191 except errors.DeviceUnresponsiveError: | 185 except errors.DeviceUnresponsiveError: |
192 pass | 186 pass |
193 else: | 187 for device_serial in devices: |
194 ProvisionDevices(options) | 188 device.WaitUntilFullyBooted(timeout=90) |
189 | |
190 ProvisionDevices(options) | |
dnj
2014/06/12 01:14:02
Sorry, I should have noticed this last time. You a
jbudorick
2014/06/12 01:20:10
Either this or move the wiping logic into Provisio
navabi
2014/06/12 18:17:30
Done. Good suggestions.
| |
195 | 191 |
196 | 192 |
197 if __name__ == '__main__': | 193 if __name__ == '__main__': |
198 sys.exit(main(sys.argv)) | 194 sys.exit(main(sys.argv)) |
OLD | NEW |