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

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: 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>]
11 """ 11 """
12 12
13 import argparse 13 import argparse
14 import glob
jbudorick 2015/03/04 00:20:46 nit: remove this
14 import logging 15 import logging
15 import os 16 import os
16 import posixpath 17 import posixpath
17 import re 18 import re
18 import subprocess 19 import subprocess
19 import sys 20 import sys
20 import time 21 import time
21 22
22 from pylib import android_commands 23 from pylib import android_commands
23 from pylib import constants 24 from pylib import constants
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 device: the device to wipe 139 device: the device to wipe
139 """ 140 """
140 device_authorized = device.FileExists(constants.ADB_KEYS_FILE) 141 device_authorized = device.FileExists(constants.ADB_KEYS_FILE)
141 if device_authorized: 142 if device_authorized:
142 adb_keys = device.ReadFile(constants.ADB_KEYS_FILE, 143 adb_keys = device.ReadFile(constants.ADB_KEYS_FILE,
143 as_root=True).splitlines() 144 as_root=True).splitlines()
144 device.RunShellCommand('wipe data', as_root=True) 145 device.RunShellCommand('wipe data', as_root=True)
145 if device_authorized: 146 if device_authorized:
146 adb_keys_set = set(adb_keys) 147 adb_keys_set = set(adb_keys)
147 for adb_key_file in options.adb_key_files or []: 148 for adb_key_file in options.adb_key_files or []:
148 with open(adb_key_file, 'r') as f: 149 try:
149 adb_public_keys = f.readlines() 150 with open(adb_key_file, 'r') as f:
150 adb_keys_set.update(adb_public_keys) 151 adb_public_keys = f.readlines()
152 adb_keys_set.update(adb_public_keys)
153 except IOError:
154 logging.warning('Unable to find adb keys file %s.' % adb_key_file)
151 WriteAdbKeysFile(device, '\n'.join(adb_keys_set)) 155 WriteAdbKeysFile(device, '\n'.join(adb_keys_set))
152 156
153 157
154 def WipeDeviceIfPossible(device, timeout, options): 158 def WipeDeviceIfPossible(device, timeout, options):
155 try: 159 try:
156 device.EnableRoot() 160 device.EnableRoot()
157 WipeDeviceData(device, options) 161 WipeDeviceData(device, options)
158 device.Reboot(True, timeout=timeout, retries=0) 162 device.Reboot(True, timeout=timeout, retries=0)
159 except (errors.DeviceUnresponsiveError, device_errors.CommandFailedError): 163 except (errors.DeviceUnresponsiveError, device_errors.CommandFailedError):
160 pass 164 pass
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 parser.add_argument('--adb-key-files', type=str, nargs='+', 296 parser.add_argument('--adb-key-files', type=str, nargs='+',
293 help='list of adb keys to push to device') 297 help='list of adb keys to push to device')
294 args = parser.parse_args() 298 args = parser.parse_args()
295 constants.SetBuildType(args.target) 299 constants.SetBuildType(args.target)
296 300
297 return ProvisionDevices(args) 301 return ProvisionDevices(args)
298 302
299 303
300 if __name__ == '__main__': 304 if __name__ == '__main__':
301 sys.exit(main()) 305 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