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

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

Issue 1078623003: [Android] Make provision_devices.KillHostHeartbeat public again. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 if options.skip_wipe: 110 if options.skip_wipe:
111 return 111 return
112 112
113 device.EnableRoot() 113 device.EnableRoot()
114 device_authorized = device.FileExists(constants.ADB_KEYS_FILE) 114 device_authorized = device.FileExists(constants.ADB_KEYS_FILE)
115 if device_authorized: 115 if device_authorized:
116 adb_keys = device.ReadFile(constants.ADB_KEYS_FILE, 116 adb_keys = device.ReadFile(constants.ADB_KEYS_FILE,
117 as_root=True).splitlines() 117 as_root=True).splitlines()
118 try: 118 try:
119 device.RunShellCommand(['wipe', 'data'], 119 device.RunShellCommand(['wipe', 'data'],
120 as_root=True, check_return=True, retries=0) 120 as_root=True, check_return=True)
121 except device_errors.CommandFailedError: 121 except device_errors.CommandFailedError:
122 logging.exception('Possible failure while wiping the device. ' 122 logging.exception('Possible failure while wiping the device. '
123 'Attempting to continue.') 123 'Attempting to continue.')
124 device.adb.WaitForDevice() 124 device.adb.WaitForDevice()
125 125
126 if device_authorized: 126 if device_authorized:
127 adb_keys_set = set(adb_keys) 127 adb_keys_set = set(adb_keys)
128 for adb_key_file in options.adb_key_files or []: 128 for adb_key_file in options.adb_key_files or []:
129 try: 129 try:
130 with open(adb_key_file, 'r') as f: 130 with open(adb_key_file, 'r') as f:
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 device.PushChangedFiles([(adb_reboot, '/data/local/tmp/')]) 246 device.PushChangedFiles([(adb_reboot, '/data/local/tmp/')])
247 # Launch adb_reboot 247 # Launch adb_reboot
248 logging.info(' Launching adb_reboot ...') 248 logging.info(' Launching adb_reboot ...')
249 device.RunShellCommand( 249 device.RunShellCommand(
250 [device.GetDevicePieWrapper(), '/data/local/tmp/adb_reboot'], 250 [device.GetDevicePieWrapper(), '/data/local/tmp/adb_reboot'],
251 check_return=True) 251 check_return=True)
252 252
253 253
254 def _LaunchHostHeartbeat(): 254 def _LaunchHostHeartbeat():
255 # Kill if existing host_heartbeat 255 # Kill if existing host_heartbeat
256 _KillHostHeartbeat() 256 KillHostHeartbeat()
257 # Launch a new host_heartbeat 257 # Launch a new host_heartbeat
258 logging.info('Spawning host heartbeat...') 258 logging.info('Spawning host heartbeat...')
259 subprocess.Popen([os.path.join(constants.DIR_SOURCE_ROOT, 259 subprocess.Popen([os.path.join(constants.DIR_SOURCE_ROOT,
260 'build/android/host_heartbeat.py')]) 260 'build/android/host_heartbeat.py')])
261 261
262 262
263 def _KillHostHeartbeat(): 263 def KillHostHeartbeat():
264 ps = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE) 264 ps = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
265 stdout, _ = ps.communicate() 265 stdout, _ = ps.communicate()
266 matches = re.findall('\\n.*host_heartbeat.*', stdout) 266 matches = re.findall('\\n.*host_heartbeat.*', stdout)
267 for match in matches: 267 for match in matches:
268 logging.info('An instance of host heart beart running... will kill') 268 logging.info('An instance of host heart beart running... will kill')
269 pid = re.findall(r'(\S+)', match)[1] 269 pid = re.findall(r'(\S+)', match)[1]
270 subprocess.call(['kill', str(pid)]) 270 subprocess.call(['kill', str(pid)])
271 271
272 272
273 def main(): 273 def main():
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 args = parser.parse_args() 317 args = parser.parse_args()
318 constants.SetBuildType(args.target) 318 constants.SetBuildType(args.target)
319 319
320 run_tests_helper.SetLogLevel(args.verbose) 320 run_tests_helper.SetLogLevel(args.verbose)
321 321
322 return ProvisionDevices(args) 322 return ProvisionDevices(args)
323 323
324 324
325 if __name__ == '__main__': 325 if __name__ == '__main__':
326 sys.exit(main()) 326 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