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

Side by Side Diff: build/android/pylib/utils/test_environment.py

Issue 221823011: [Android] Change object types from AndroidCommands to DeviceUtils in build/android/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Frank's comments. Created 6 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
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 import psutil 6 import psutil
7 import signal 7 import signal
8 8
9 from pylib import android_commands 9 from pylib import android_commands
10 10 from pylib.device import device_utils
11 11
12 def _KillWebServers(): 12 def _KillWebServers():
13 for s in [signal.SIGTERM, signal.SIGINT, signal.SIGQUIT, signal.SIGKILL]: 13 for s in [signal.SIGTERM, signal.SIGINT, signal.SIGQUIT, signal.SIGKILL]:
14 signalled = [] 14 signalled = []
15 for server in ['lighttpd', 'webpagereplay']: 15 for server in ['lighttpd', 'webpagereplay']:
16 for p in psutil.process_iter(): 16 for p in psutil.process_iter():
17 try: 17 try:
18 if not server in ' '.join(p.cmdline): 18 if not server in ' '.join(p.cmdline):
19 continue 19 continue
20 logging.info('Killing %s %s %s', s, server, p.pid) 20 logging.info('Killing %s %s %s', s, server, p.pid)
21 p.send_signal(s) 21 p.send_signal(s)
22 signalled.append(p) 22 signalled.append(p)
23 except Exception as e: 23 except Exception as e:
24 logging.warning('Failed killing %s %s %s', server, p.pid, e) 24 logging.warning('Failed killing %s %s %s', server, p.pid, e)
25 for p in signalled: 25 for p in signalled:
26 try: 26 try:
27 p.wait(1) 27 p.wait(1)
28 except Exception as e: 28 except Exception as e:
29 logging.warning('Failed waiting for %s to die. %s', p.pid, e) 29 logging.warning('Failed waiting for %s to die. %s', p.pid, e)
30 30
31 31
32 32
33 def CleanupLeftoverProcesses(): 33 def CleanupLeftoverProcesses():
34 """Clean up the test environment, restarting fresh adb and HTTP daemons.""" 34 """Clean up the test environment, restarting fresh adb and HTTP daemons."""
35 _KillWebServers() 35 _KillWebServers()
36 did_restart_host_adb = False 36 did_restart_host_adb = False
37 for device in android_commands.GetAttachedDevices(): 37 for device_serial in android_commands.GetAttachedDevices():
38 adb = android_commands.AndroidCommands(device) 38 device = device_utils.DeviceUtils(device_serial)
39 # Make sure we restart the host adb server only once. 39 # Make sure we restart the host adb server only once.
40 if not did_restart_host_adb: 40 if not did_restart_host_adb:
41 adb.RestartAdbServer() 41 device.old_interface.RestartAdbServer()
42 did_restart_host_adb = True 42 did_restart_host_adb = True
43 adb.RestartAdbdOnDevice() 43 device.old_interface.RestartAdbdOnDevice()
44 adb.EnableAdbRoot() 44 device.old_interface.EnableAdbRoot()
45 adb.WaitForDevicePm() 45 device.old_interface.WaitForDevicePm()
46
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698