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

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

Issue 754433003: Update from https://crrev.com/305340 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 | « build/android/install_emulator_deps.py ('k') | build/android/pylib/android_commands.py » ('j') | 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 13 matching lines...) Expand all
24 from pylib.device import device_blacklist 24 from pylib.device import device_blacklist
25 from pylib.device import device_errors 25 from pylib.device import device_errors
26 from pylib.device import device_utils 26 from pylib.device import device_utils
27 from pylib.utils import run_tests_helper 27 from pylib.utils import run_tests_helper
28 28
29 sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT, 29 sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT,
30 'third_party', 'android_testrunner')) 30 'third_party', 'android_testrunner'))
31 import errors 31 import errors
32 32
33 def KillHostHeartbeat(): 33 def KillHostHeartbeat():
34 ps = subprocess.Popen(['ps', 'aux'], stdout = subprocess.PIPE) 34 ps = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
35 stdout, _ = ps.communicate() 35 stdout, _ = ps.communicate()
36 matches = re.findall('\\n.*host_heartbeat.*', stdout) 36 matches = re.findall('\\n.*host_heartbeat.*', stdout)
37 for match in matches: 37 for match in matches:
38 logging.info('An instance of host heart beart running... will kill') 38 logging.info('An instance of host heart beart running... will kill')
39 pid = re.findall('(\S+)', match)[1] 39 pid = re.findall(r'(\S+)', match)[1]
40 subprocess.call(['kill', str(pid)]) 40 subprocess.call(['kill', str(pid)])
41 41
42 42
43 def LaunchHostHeartbeat(): 43 def LaunchHostHeartbeat():
44 # Kill if existing host_heartbeat 44 # Kill if existing host_heartbeat
45 KillHostHeartbeat() 45 KillHostHeartbeat()
46 # Launch a new host_heartbeat 46 # Launch a new host_heartbeat
47 logging.info('Spawning host heartbeat...') 47 logging.info('Spawning host heartbeat...')
48 subprocess.Popen([os.path.join(constants.DIR_SOURCE_ROOT, 48 subprocess.Popen([os.path.join(constants.DIR_SOURCE_ROOT,
49 'build/android/host_heartbeat.py')]) 49 'build/android/host_heartbeat.py')])
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 if not device.old_interface.IsDeviceCharging(): 183 if not device.old_interface.IsDeviceCharging():
184 if device.old_interface.CanControlUsbCharging(): 184 if device.old_interface.CanControlUsbCharging():
185 device.old_interface.EnableUsbCharging() 185 device.old_interface.EnableUsbCharging()
186 else: 186 else:
187 logging.error('Device is not charging') 187 logging.error('Device is not charging')
188 break 188 break
189 logging.info('Waiting for device to charge. Current level=%s', 189 logging.info('Waiting for device to charge. Current level=%s',
190 battery_info.get('level', 0)) 190 battery_info.get('level', 0))
191 time.sleep(60) 191 time.sleep(60)
192 battery_info = device.old_interface.GetBatteryInfo() 192 battery_info = device.old_interface.GetBatteryInfo()
193 # TODO(jbudorick): Tune the timeout per OS version. 193 if not options.skip_wipe:
194 device.Reboot(True, timeout=600, retries=0) 194 # TODO(jbudorick): Tune the timeout per OS version.
195 device.Reboot(True, timeout=600, retries=0)
195 device.RunShellCommand('date -s %s' % time.strftime('%Y%m%d.%H%M%S', 196 device.RunShellCommand('date -s %s' % time.strftime('%Y%m%d.%H%M%S',
196 time.gmtime()), 197 time.gmtime()),
197 as_root=True) 198 as_root=True)
198 props = device.RunShellCommand('getprop') 199 props = device.RunShellCommand('getprop')
199 for prop in props: 200 for prop in props:
200 logging.info(' %s' % prop) 201 logging.info(' %s' % prop)
201 if options.auto_reconnect: 202 if options.auto_reconnect:
202 PushAndLaunchAdbReboot(device, options.target) 203 PushAndLaunchAdbReboot(device, options.target)
203 except (errors.WaitForResponseTimedOutError, 204 except (errors.WaitForResponseTimedOutError,
204 device_errors.CommandTimeoutError): 205 device_errors.CommandTimeoutError):
205 logging.info('Timed out waiting for device %s. Adding to blacklist.', 206 logging.info('Timed out waiting for device %s. Adding to blacklist.',
206 str(device)) 207 str(device))
207 # Device black list is reset by bb_device_status_check.py per build. 208 # Device black list is reset by bb_device_status_check.py per build.
208 device_blacklist.ExtendBlacklist([str(device)]) 209 device_blacklist.ExtendBlacklist([str(device)])
209 except (device_errors.CommandFailedError): 210 except device_errors.CommandFailedError:
210 logging.exception('Failed to provision device %s. Adding to blacklist.', 211 logging.exception('Failed to provision device %s. Adding to blacklist.',
211 str(device)) 212 str(device))
212 device_blacklist.ExtendBlacklist([str(device)]) 213 device_blacklist.ExtendBlacklist([str(device)])
213 214
214 215
215 def ProvisionDevices(options): 216 def ProvisionDevices(options):
216 is_perf = 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower() 217 is_perf = 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower()
217 if options.device is not None: 218 if options.device is not None:
218 devices = [options.device] 219 devices = [options.device]
219 else: 220 else:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 252
252 if args: 253 if args:
253 print >> sys.stderr, 'Unused args %s' % args 254 print >> sys.stderr, 'Unused args %s' % args
254 return 1 255 return 1
255 256
256 return ProvisionDevices(options) 257 return ProvisionDevices(options)
257 258
258 259
259 if __name__ == '__main__': 260 if __name__ == '__main__':
260 sys.exit(main(sys.argv)) 261 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « build/android/install_emulator_deps.py ('k') | build/android/pylib/android_commands.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698