OLD | NEW |
(Empty) | |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import logging |
| 6 import os |
| 7 import psutil |
| 8 |
| 9 from pylib import android_commands |
| 10 from pylib import ports |
| 11 |
| 12 def _KillWebServers(): |
| 13 for retry in xrange(5): |
| 14 for server in ['lighttpd', 'web-page-replay']: |
| 15 pids = [p.pid for p in psutil.process_iter() if server in p.name] |
| 16 for pid in pids: |
| 17 try: |
| 18 logging.warning('Killing %s %s', server, pid) |
| 19 os.kill(pid, signal.SIGQUIT) |
| 20 except Exception as e: |
| 21 logging.warning('Failed killing %s %s %s', server, pid, e) |
| 22 |
| 23 |
| 24 def CleanupLeftoverProcesses(): |
| 25 """Clean up the test environment, restarting fresh adb and HTTP daemons.""" |
| 26 _KillWebServers() |
| 27 did_restart_host_adb = False |
| 28 for device in android_commands.GetAttachedDevices(): |
| 29 adb = android_commands.AndroidCommands(device) |
| 30 # Make sure we restart the host adb server only once. |
| 31 if not did_restart_host_adb: |
| 32 adb.RestartAdbServer() |
| 33 did_restart_host_adb = True |
| 34 adb.RestartAdbdOnDevice() |
| 35 adb.EnableAdbRoot() |
| 36 adb.WaitForDevicePm() |
OLD | NEW |