Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: build/android/provision_devices.py

Issue 975963002: Catch exception if --adb-key-files file does not exist and log warning. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary import glob. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 device: the device to wipe 138 device: the device to wipe
139 """ 139 """
140 device_authorized = device.FileExists(constants.ADB_KEYS_FILE) 140 device_authorized = device.FileExists(constants.ADB_KEYS_FILE)
141 if device_authorized: 141 if device_authorized:
142 adb_keys = device.ReadFile(constants.ADB_KEYS_FILE, 142 adb_keys = device.ReadFile(constants.ADB_KEYS_FILE,
143 as_root=True).splitlines() 143 as_root=True).splitlines()
144 device.RunShellCommand('wipe data', as_root=True) 144 device.RunShellCommand('wipe data', as_root=True)
145 if device_authorized: 145 if device_authorized:
146 adb_keys_set = set(adb_keys) 146 adb_keys_set = set(adb_keys)
147 for adb_key_file in options.adb_key_files or []: 147 for adb_key_file in options.adb_key_files or []:
148 with open(adb_key_file, 'r') as f: 148 try:
149 adb_public_keys = f.readlines() 149 with open(adb_key_file, 'r') as f:
150 adb_keys_set.update(adb_public_keys) 150 adb_public_keys = f.readlines()
151 adb_keys_set.update(adb_public_keys)
152 except IOError:
153 logging.warning('Unable to find adb keys file %s.' % adb_key_file)
151 WriteAdbKeysFile(device, '\n'.join(adb_keys_set)) 154 WriteAdbKeysFile(device, '\n'.join(adb_keys_set))
152 155
153 156
154 def WipeDeviceIfPossible(device, timeout, options): 157 def WipeDeviceIfPossible(device, timeout, options):
155 try: 158 try:
156 device.EnableRoot() 159 device.EnableRoot()
157 WipeDeviceData(device, options) 160 WipeDeviceData(device, options)
158 device.Reboot(True, timeout=timeout, retries=0) 161 device.Reboot(True, timeout=timeout, retries=0)
159 except (errors.DeviceUnresponsiveError, device_errors.CommandFailedError): 162 except (errors.DeviceUnresponsiveError, device_errors.CommandFailedError):
160 pass 163 pass
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 parser.add_argument('--adb-key-files', type=str, nargs='+', 295 parser.add_argument('--adb-key-files', type=str, nargs='+',
293 help='list of adb keys to push to device') 296 help='list of adb keys to push to device')
294 args = parser.parse_args() 297 args = parser.parse_args()
295 constants.SetBuildType(args.target) 298 constants.SetBuildType(args.target)
296 299
297 return ProvisionDevices(args) 300 return ProvisionDevices(args)
298 301
299 302
300 if __name__ == '__main__': 303 if __name__ == '__main__':
301 sys.exit(main()) 304 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698