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 | 281 |
282 Args: | 282 Args: |
283 device: A DeviceUtils instance. | 283 device: A DeviceUtils instance. |
284 tool: Tool class to use to get wrapper, if necessary, for executing the | 284 tool: Tool class to use to get wrapper, if necessary, for executing the |
285 forwarder (see valgrind_tools.py). | 285 forwarder (see valgrind_tools.py). |
286 """ | 286 """ |
287 device_serial = str(device) | 287 device_serial = str(device) |
288 if device_serial in self._initialized_devices: | 288 if device_serial in self._initialized_devices: |
289 return | 289 return |
290 Forwarder._KillDeviceLocked(device, tool) | 290 Forwarder._KillDeviceLocked(device, tool) |
291 device.PushChangedFiles( | 291 device.PushChangedFiles([( |
292 self._device_forwarder_path_on_host, | 292 self._device_forwarder_path_on_host, |
293 Forwarder._DEVICE_FORWARDER_FOLDER) | 293 Forwarder._DEVICE_FORWARDER_FOLDER)]) |
294 cmd = '%s %s' % (tool.GetUtilWrapper(), Forwarder._DEVICE_FORWARDER_PATH) | 294 cmd = '%s %s' % (tool.GetUtilWrapper(), Forwarder._DEVICE_FORWARDER_PATH) |
295 (exit_code, output) = device.old_interface.GetAndroidToolStatusAndOutput( | 295 (exit_code, output) = device.old_interface.GetAndroidToolStatusAndOutput( |
296 cmd, lib_path=Forwarder._DEVICE_FORWARDER_FOLDER) | 296 cmd, lib_path=Forwarder._DEVICE_FORWARDER_FOLDER) |
297 if exit_code != 0: | 297 if exit_code != 0: |
298 raise Exception( | 298 raise Exception( |
299 'Failed to start device forwarder:\n%s' % '\n'.join(output)) | 299 'Failed to start device forwarder:\n%s' % '\n'.join(output)) |
300 self._initialized_devices.add(device_serial) | 300 self._initialized_devices.add(device_serial) |
301 | 301 |
302 def _KillHostLocked(self): | 302 def _KillHostLocked(self): |
303 """Kills the forwarder process running on the host. | 303 """Kills the forwarder process running on the host. |
(...skipping 23 matching lines...) Expand all Loading... |
327 """ | 327 """ |
328 logging.info('Killing device_forwarder.') | 328 logging.info('Killing device_forwarder.') |
329 Forwarder._instance._initialized_devices.discard(str(device)) | 329 Forwarder._instance._initialized_devices.discard(str(device)) |
330 if not device.FileExists(Forwarder._DEVICE_FORWARDER_PATH): | 330 if not device.FileExists(Forwarder._DEVICE_FORWARDER_PATH): |
331 return | 331 return |
332 | 332 |
333 cmd = '%s %s --kill-server' % (tool.GetUtilWrapper(), | 333 cmd = '%s %s --kill-server' % (tool.GetUtilWrapper(), |
334 Forwarder._DEVICE_FORWARDER_PATH) | 334 Forwarder._DEVICE_FORWARDER_PATH) |
335 device.old_interface.GetAndroidToolStatusAndOutput( | 335 device.old_interface.GetAndroidToolStatusAndOutput( |
336 cmd, lib_path=Forwarder._DEVICE_FORWARDER_FOLDER) | 336 cmd, lib_path=Forwarder._DEVICE_FORWARDER_FOLDER) |
OLD | NEW |