| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 """ | 119 """ |
| 120 device_authorized = device.FileExists(constants.ADB_KEYS_FILE) | 120 device_authorized = device.FileExists(constants.ADB_KEYS_FILE) |
| 121 if device_authorized: | 121 if device_authorized: |
| 122 adb_keys = device.RunShellCommand('cat %s' % constants.ADB_KEYS_FILE, | 122 adb_keys = device.RunShellCommand('cat %s' % constants.ADB_KEYS_FILE, |
| 123 as_root=True) | 123 as_root=True) |
| 124 device.RunShellCommand('wipe data', as_root=True) | 124 device.RunShellCommand('wipe data', as_root=True) |
| 125 if device_authorized: | 125 if device_authorized: |
| 126 path_list = constants.ADB_KEYS_FILE.split('/') | 126 path_list = constants.ADB_KEYS_FILE.split('/') |
| 127 dir_path = '/'.join(path_list[:len(path_list)-1]) | 127 dir_path = '/'.join(path_list[:len(path_list)-1]) |
| 128 device.RunShellCommand('mkdir -p %s' % dir_path, as_root=True) | 128 device.RunShellCommand('mkdir -p %s' % dir_path, as_root=True) |
| 129 device.RunShellCommand('restorecon %s' % dir_path, as_root=True) |
| 129 device.RunShellCommand('echo %s > %s' % | 130 device.RunShellCommand('echo %s > %s' % |
| 130 (adb_keys[0], constants.ADB_KEYS_FILE)) | 131 (adb_keys[0], constants.ADB_KEYS_FILE), as_root=True) |
| 131 for adb_key in adb_keys[1:]: | 132 for adb_key in adb_keys[1:]: |
| 132 device.RunShellCommand( | 133 device.RunShellCommand( |
| 133 'echo %s >> %s' % (adb_key, constants.ADB_KEYS_FILE)) | 134 'echo %s >> %s' % (adb_key, constants.ADB_KEYS_FILE), as_root=True) |
| 135 device.RunShellCommand('restorecon %s' % constants.ADB_KEYS_FILE, |
| 136 as_root=True) |
| 134 | 137 |
| 135 | 138 |
| 136 def ProvisionDevices(options): | 139 def ProvisionDevices(options): |
| 137 is_perf = 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower() | 140 is_perf = 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower() |
| 138 # TODO(jbudorick): Parallelize provisioning of all attached devices after | 141 # TODO(jbudorick): Parallelize provisioning of all attached devices after |
| 139 # switching from AndroidCommands. | 142 # switching from AndroidCommands. |
| 140 if options.device is not None: | 143 if options.device is not None: |
| 141 devices = [options.device] | 144 devices = [options.device] |
| 142 else: | 145 else: |
| 143 devices = android_commands.GetAttachedDevices() | 146 devices = android_commands.GetAttachedDevices() |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 230 |
| 228 if args: | 231 if args: |
| 229 print >> sys.stderr, 'Unused args %s' % args | 232 print >> sys.stderr, 'Unused args %s' % args |
| 230 return 1 | 233 return 1 |
| 231 | 234 |
| 232 ProvisionDevices(options) | 235 ProvisionDevices(options) |
| 233 | 236 |
| 234 | 237 |
| 235 if __name__ == '__main__': | 238 if __name__ == '__main__': |
| 236 sys.exit(main(sys.argv)) | 239 sys.exit(main(sys.argv)) |
| OLD | NEW |