| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 # pylint: disable=W0212 | 5 # pylint: disable=W0212 |
| 6 | 6 |
| 7 import fcntl | 7 import fcntl |
| 8 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 import psutil | 10 import psutil |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 forwarder (see valgrind_tools.py). | 281 forwarder (see valgrind_tools.py). |
| 282 """ | 282 """ |
| 283 device_serial = str(device) | 283 device_serial = str(device) |
| 284 if device_serial in self._initialized_devices: | 284 if device_serial in self._initialized_devices: |
| 285 return | 285 return |
| 286 Forwarder._KillDeviceLocked(device, tool) | 286 Forwarder._KillDeviceLocked(device, tool) |
| 287 device.PushChangedFiles([( | 287 device.PushChangedFiles([( |
| 288 self._device_forwarder_path_on_host, | 288 self._device_forwarder_path_on_host, |
| 289 Forwarder._DEVICE_FORWARDER_FOLDER)]) | 289 Forwarder._DEVICE_FORWARDER_FOLDER)]) |
| 290 cmd = '%s %s' % (tool.GetUtilWrapper(), Forwarder._DEVICE_FORWARDER_PATH) | 290 cmd = '%s %s' % (tool.GetUtilWrapper(), Forwarder._DEVICE_FORWARDER_PATH) |
| 291 (exit_code, output) = device.old_interface.GetAndroidToolStatusAndOutput( | 291 device.RunShellCommand( |
| 292 cmd, lib_path=Forwarder._DEVICE_FORWARDER_FOLDER) | 292 cmd, env={'LD_LIBRARY_PATH': Forwarder._DEVICE_FORWARDER_FOLDER}) |
| 293 if exit_code != 0: | |
| 294 raise Exception( | |
| 295 'Failed to start device forwarder:\n%s' % '\n'.join(output)) | |
| 296 self._initialized_devices.add(device_serial) | 293 self._initialized_devices.add(device_serial) |
| 297 | 294 |
| 298 def _KillHostLocked(self): | 295 def _KillHostLocked(self): |
| 299 """Kills the forwarder process running on the host. | 296 """Kills the forwarder process running on the host. |
| 300 | 297 |
| 301 Note that the global lock must be acquired before calling this method. | 298 Note that the global lock must be acquired before calling this method. |
| 302 """ | 299 """ |
| 303 logging.info('Killing host_forwarder.') | 300 logging.info('Killing host_forwarder.') |
| 304 (exit_code, output) = cmd_helper.GetCmdStatusAndOutput( | 301 (exit_code, output) = cmd_helper.GetCmdStatusAndOutput( |
| 305 [self._host_forwarder_path, '--kill-server']) | 302 [self._host_forwarder_path, '--kill-server']) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 321 tool: Wrapper tool (e.g. valgrind) that can be used to execute the device | 318 tool: Wrapper tool (e.g. valgrind) that can be used to execute the device |
| 322 forwarder (see valgrind_tools.py). | 319 forwarder (see valgrind_tools.py). |
| 323 """ | 320 """ |
| 324 logging.info('Killing device_forwarder.') | 321 logging.info('Killing device_forwarder.') |
| 325 Forwarder._instance._initialized_devices.discard(str(device)) | 322 Forwarder._instance._initialized_devices.discard(str(device)) |
| 326 if not device.FileExists(Forwarder._DEVICE_FORWARDER_PATH): | 323 if not device.FileExists(Forwarder._DEVICE_FORWARDER_PATH): |
| 327 return | 324 return |
| 328 | 325 |
| 329 cmd = '%s %s --kill-server' % (tool.GetUtilWrapper(), | 326 cmd = '%s %s --kill-server' % (tool.GetUtilWrapper(), |
| 330 Forwarder._DEVICE_FORWARDER_PATH) | 327 Forwarder._DEVICE_FORWARDER_PATH) |
| 331 device.old_interface.GetAndroidToolStatusAndOutput( | 328 device.RunShellCommand( |
| 332 cmd, lib_path=Forwarder._DEVICE_FORWARDER_FOLDER) | 329 cmd, env={'LD_LIBRARY_PATH': Forwarder._DEVICE_FORWARDER_FOLDER}) |
| OLD | NEW |