| 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 """Pushes and launches the adb_reboot binary on the device. | 225 """Pushes and launches the adb_reboot binary on the device. |
| 226 | 226 |
| 227 Arguments: | 227 Arguments: |
| 228 device: The DeviceUtils instance for the device to which the adb_reboot | 228 device: The DeviceUtils instance for the device to which the adb_reboot |
| 229 binary should be pushed. | 229 binary should be pushed. |
| 230 target: The build target (example, Debug or Release) which helps in | 230 target: The build target (example, Debug or Release) which helps in |
| 231 locating the adb_reboot binary. | 231 locating the adb_reboot binary. |
| 232 """ | 232 """ |
| 233 logging.info('Will push and launch adb_reboot on %s' % str(device)) | 233 logging.info('Will push and launch adb_reboot on %s' % str(device)) |
| 234 # Kill if adb_reboot is already running. | 234 # Kill if adb_reboot is already running. |
| 235 try: | 235 device.KillAll('adb_reboot', blocking=True, timeout=2, quiet=True) |
| 236 # Don't try to kill adb_reboot more than once. We don't expect it to be | |
| 237 # running at all. | |
| 238 device.KillAll('adb_reboot', blocking=True, timeout=2, retries=0) | |
| 239 except device_errors.CommandFailedError: | |
| 240 # We can safely ignore the exception because we don't expect adb_reboot | |
| 241 # to be running. | |
| 242 pass | |
| 243 # Push adb_reboot | 236 # Push adb_reboot |
| 244 logging.info(' Pushing adb_reboot ...') | 237 logging.info(' Pushing adb_reboot ...') |
| 245 adb_reboot = os.path.join(constants.DIR_SOURCE_ROOT, | 238 adb_reboot = os.path.join(constants.DIR_SOURCE_ROOT, |
| 246 'out/%s/adb_reboot' % target) | 239 'out/%s/adb_reboot' % target) |
| 247 device.PushChangedFiles([(adb_reboot, '/data/local/tmp/')]) | 240 device.PushChangedFiles([(adb_reboot, '/data/local/tmp/')]) |
| 248 # Launch adb_reboot | 241 # Launch adb_reboot |
| 249 logging.info(' Launching adb_reboot ...') | 242 logging.info(' Launching adb_reboot ...') |
| 250 device.RunShellCommand( | 243 device.RunShellCommand( |
| 251 [device.GetDevicePieWrapper(), '/data/local/tmp/adb_reboot'], | 244 [device.GetDevicePieWrapper(), '/data/local/tmp/adb_reboot'], |
| 252 check_return=True) | 245 check_return=True) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 args = parser.parse_args() | 311 args = parser.parse_args() |
| 319 constants.SetBuildType(args.target) | 312 constants.SetBuildType(args.target) |
| 320 | 313 |
| 321 run_tests_helper.SetLogLevel(args.verbose) | 314 run_tests_helper.SetLogLevel(args.verbose) |
| 322 | 315 |
| 323 return ProvisionDevices(args) | 316 return ProvisionDevices(args) |
| 324 | 317 |
| 325 | 318 |
| 326 if __name__ == '__main__': | 319 if __name__ == '__main__': |
| 327 sys.exit(main()) | 320 sys.exit(main()) |
| OLD | NEW |