| OLD | NEW |
| 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 from pylib.device import device_errors |
| 10 from pylib.device import device_utils | 11 from pylib.device import device_utils |
| 11 | 12 |
| 13 |
| 12 def _KillWebServers(): | 14 def _KillWebServers(): |
| 13 for s in [signal.SIGTERM, signal.SIGINT, signal.SIGQUIT, signal.SIGKILL]: | 15 for s in [signal.SIGTERM, signal.SIGINT, signal.SIGQUIT, signal.SIGKILL]: |
| 14 signalled = [] | 16 signalled = [] |
| 15 for server in ['lighttpd', 'webpagereplay']: | 17 for server in ['lighttpd', 'webpagereplay']: |
| 16 for p in psutil.process_iter(): | 18 for p in psutil.process_iter(): |
| 17 try: | 19 try: |
| 18 if not server in ' '.join(p.cmdline): | 20 if not server in ' '.join(p.cmdline): |
| 19 continue | 21 continue |
| 20 logging.info('Killing %s %s %s', s, server, p.pid) | 22 logging.info('Killing %s %s %s', s, server, p.pid) |
| 21 p.send_signal(s) | 23 p.send_signal(s) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 34 """Clean up the test environment, restarting fresh adb and HTTP daemons.""" | 36 """Clean up the test environment, restarting fresh adb and HTTP daemons.""" |
| 35 _KillWebServers() | 37 _KillWebServers() |
| 36 did_restart_host_adb = False | 38 did_restart_host_adb = False |
| 37 for device_serial in android_commands.GetAttachedDevices(): | 39 for device_serial in android_commands.GetAttachedDevices(): |
| 38 device = device_utils.DeviceUtils(device_serial) | 40 device = device_utils.DeviceUtils(device_serial) |
| 39 # Make sure we restart the host adb server only once. | 41 # Make sure we restart the host adb server only once. |
| 40 if not did_restart_host_adb: | 42 if not did_restart_host_adb: |
| 41 device_utils.RestartServer() | 43 device_utils.RestartServer() |
| 42 did_restart_host_adb = True | 44 did_restart_host_adb = True |
| 43 device.old_interface.RestartAdbdOnDevice() | 45 device.old_interface.RestartAdbdOnDevice() |
| 44 device.old_interface.EnableAdbRoot() | 46 try: |
| 47 device.EnableRoot() |
| 48 except device_errors.CommandFailedError as e: |
| 49 # TODO(jbudorick) Handle this exception appropriately after interface |
| 50 # conversions are finished. |
| 51 logging.error(str(e)) |
| 45 device.old_interface.WaitForDevicePm() | 52 device.old_interface.WaitForDevicePm() |
| 46 | 53 |
| OLD | NEW |