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

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

Issue 99713002: Factor out a system_properties interface for interacting with getprop/setprop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use shlex.split() Created 7 years 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 | Annotate | Revision Log
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 os 6 import os
7 import psutil 7 import psutil
8 8
9 from pylib import android_commands 9 from pylib import android_commands
10 10
11 def _KillWebServers(): 11 def _KillWebServers():
12 for retry in xrange(5): 12 for retry in xrange(5):
13 for server in ['lighttpd', 'web-page-replay']: 13 for server in ['lighttpd', 'web-page-replay']:
14 pids = [p.pid for p in psutil.process_iter() if server in p.name] 14 pids = [p.pid for p in psutil.process_iter() if server in p.name]
15 for pid in pids: 15 for pid in pids:
16 try: 16 try:
17 logging.warning('Killing %s %s', server, pid) 17 logging.warning('Killing %s %s', server, pid)
18 os.kill(pid, signal.SIGQUIT) 18 os.kill(pid, signal.SIGQUIT)
19 except Exception as e: 19 except Exception as e:
20 logging.warning('Failed killing %s %s %s', server, pid, e) 20 logging.warning('Failed killing %s %s %s', server, pid, e)
21 21
22 22
23 def CleanupLeftoverProcesses(): 23 def CleanupLeftoverProcesses():
24 """Clean up the test environment, restarting fresh adb and HTTP daemons.""" 24 """Clean up the test environment, restarting fresh adb and HTTP daemons."""
25 _KillWebServers() 25 _KillWebServers()
26 did_restart_host_adb = False 26 did_restart_host_adb = False
27 for device in android_commands.GetAttachedDevices(): 27 for device in android_commands.GetAttachedDevices():
28 adb = android_commands.AndroidCommands(device) 28 adb = android_commands.AndroidCommands(device, api_strict_mode=True)
29 # Make sure we restart the host adb server only once. 29 # Make sure we restart the host adb server only once.
30 if not did_restart_host_adb: 30 if not did_restart_host_adb:
31 adb.RestartAdbServer() 31 adb.RestartAdbServer()
32 did_restart_host_adb = True 32 did_restart_host_adb = True
33 adb.RestartAdbdOnDevice() 33 adb.RestartAdbdOnDevice()
34 adb.EnableAdbRoot() 34 adb.EnableAdbRoot()
35 adb.WaitForDevicePm() 35 adb.WaitForDevicePm()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698