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 import logging | 5 import logging |
6 import os | 6 import os |
7 import re | 7 import re |
8 import sys | 8 import sys |
9 import time | 9 import time |
10 | 10 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 logging.info('Command format: <ADB port>:<Device port>' + | 78 logging.info('Command format: <ADB port>:<Device port>' + |
79 '[:<Forward to port>:<Forward to address>]') | 79 '[:<Forward to port>:<Forward to address>]') |
80 logging.info('Forwarding using commands: %s', redirection_commands) | 80 logging.info('Forwarding using commands: %s', redirection_commands) |
81 if cmd_helper.RunCmd( | 81 if cmd_helper.RunCmd( |
82 ['adb', '-s', self._adb._adb.GetSerialNumber(), 'forward', | 82 ['adb', '-s', self._adb._adb.GetSerialNumber(), 'forward', |
83 'tcp:%s' % host_adb_control_port, | 83 'tcp:%s' % host_adb_control_port, |
84 'localabstract:%s' % Forwarder._DEVICE_ADB_CONTROL_PORT]) != 0: | 84 'localabstract:%s' % Forwarder._DEVICE_ADB_CONTROL_PORT]) != 0: |
85 raise Exception('Error while running adb forward.') | 85 raise Exception('Error while running adb forward.') |
86 | 86 |
87 (exit_code, output) = self._adb.GetShellCommandStatusAndOutput( | 87 (exit_code, output) = self._adb.GetShellCommandStatusAndOutput( |
88 '%s %s %s %s' % (tool.GetUtilWrapper(), Forwarder._LD_LIBRARY_PATH, | 88 '%s %s %s %s' % (Forwarder._LD_LIBRARY_PATH, tool.GetUtilWrapper(), |
89 Forwarder._DEVICE_FORWARDER_PATH, | 89 Forwarder._DEVICE_FORWARDER_PATH, |
90 Forwarder._DEVICE_ADB_CONTROL_PORT)) | 90 Forwarder._DEVICE_ADB_CONTROL_PORT)) |
91 if exit_code != 0: | 91 if exit_code != 0: |
92 raise Exception( | 92 raise Exception( |
93 'Failed to start device forwarder:\n%s' % '\n'.join(output)) | 93 'Failed to start device forwarder:\n%s' % '\n'.join(output)) |
94 | 94 |
95 for redirection_command in redirection_commands: | 95 for redirection_command in redirection_commands: |
96 try: | 96 try: |
97 (exit_code, output) = cmd_helper.GetCmdStatusAndOutput( | 97 (exit_code, output) = cmd_helper.GetCmdStatusAndOutput( |
98 [self._host_forwarder_path, redirection_command]) | 98 [self._host_forwarder_path, redirection_command]) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 148 |
149 def DevicePortForHostPort(self, host_port): | 149 def DevicePortForHostPort(self, host_port): |
150 """Get the device port that corresponds to a given host port.""" | 150 """Get the device port that corresponds to a given host port.""" |
151 return self._host_to_device_port_map.get(host_port) | 151 return self._host_to_device_port_map.get(host_port) |
152 | 152 |
153 def Close(self): | 153 def Close(self): |
154 """Terminate the forwarder process.""" | 154 """Terminate the forwarder process.""" |
155 if self._device_process: | 155 if self._device_process: |
156 self._device_process.close() | 156 self._device_process.close() |
157 self._device_process = None | 157 self._device_process = None |
OLD | NEW |