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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 try: | 89 try: |
90 (exit_code, output) = cmd_helper.GetCmdStatusAndOutput( | 90 (exit_code, output) = cmd_helper.GetCmdStatusAndOutput( |
91 [instance._host_forwarder_path] + redirection_command) | 91 [instance._host_forwarder_path] + redirection_command) |
92 except OSError as e: | 92 except OSError as e: |
93 if e.errno == 2: | 93 if e.errno == 2: |
94 raise Exception('Unable to start host forwarder. Make sure you have' | 94 raise Exception('Unable to start host forwarder. Make sure you have' |
95 ' built host_forwarder.') | 95 ' built host_forwarder.') |
96 else: raise | 96 else: raise |
97 if exit_code != 0: | 97 if exit_code != 0: |
98 Forwarder._KillDeviceLocked(device, tool) | 98 Forwarder._KillDeviceLocked(device, tool) |
| 99 # Log alive forwarders |
| 100 ps_out = device.RunShellCommand(['ps']) |
| 101 logging.info('Currently running device_forwarders:') |
| 102 for line in ps_out: |
| 103 if 'device_forwarder' in line: |
| 104 logging.info(' %s', line) |
99 raise Exception('%s exited with %d:\n%s' % ( | 105 raise Exception('%s exited with %d:\n%s' % ( |
100 instance._host_forwarder_path, exit_code, '\n'.join(output))) | 106 instance._host_forwarder_path, exit_code, '\n'.join(output))) |
101 tokens = output.split(':') | 107 tokens = output.split(':') |
102 if len(tokens) != 2: | 108 if len(tokens) != 2: |
103 raise Exception('Unexpected host forwarder output "%s", ' | 109 raise Exception('Unexpected host forwarder output "%s", ' |
104 'expected "device_port:host_port"' % output) | 110 'expected "device_port:host_port"' % output) |
105 device_port = int(tokens[0]) | 111 device_port = int(tokens[0]) |
106 host_port = int(tokens[1]) | 112 host_port = int(tokens[1]) |
107 serial_with_port = (device_serial, device_port) | 113 serial_with_port = (device_serial, device_port) |
108 instance._device_to_host_port_map[serial_with_port] = host_port | 114 instance._device_to_host_port_map[serial_with_port] = host_port |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 logging.info('Killing device_forwarder.') | 318 logging.info('Killing device_forwarder.') |
313 Forwarder._instance._initialized_devices.discard(str(device)) | 319 Forwarder._instance._initialized_devices.discard(str(device)) |
314 if not device.FileExists(Forwarder._DEVICE_FORWARDER_PATH): | 320 if not device.FileExists(Forwarder._DEVICE_FORWARDER_PATH): |
315 return | 321 return |
316 | 322 |
317 cmd = '%s %s --kill-server' % (tool.GetUtilWrapper(), | 323 cmd = '%s %s --kill-server' % (tool.GetUtilWrapper(), |
318 Forwarder._DEVICE_FORWARDER_PATH) | 324 Forwarder._DEVICE_FORWARDER_PATH) |
319 device.RunShellCommand( | 325 device.RunShellCommand( |
320 cmd, env={'LD_LIBRARY_PATH': Forwarder._DEVICE_FORWARDER_FOLDER}, | 326 cmd, env={'LD_LIBRARY_PATH': Forwarder._DEVICE_FORWARDER_FOLDER}, |
321 check_return=True) | 327 check_return=True) |
OLD | NEW |