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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 device_port = int(tokens[0]) | 100 device_port = int(tokens[0]) |
101 host_port = int(tokens[1]) | 101 host_port = int(tokens[1]) |
102 self._host_to_device_port_map[host_port] = device_port | 102 self._host_to_device_port_map[host_port] = device_port |
103 logging.info('Forwarding device port: %d to host port: %d.', device_port, | 103 logging.info('Forwarding device port: %d to host port: %d.', device_port, |
104 host_port) | 104 host_port) |
105 | 105 |
106 @staticmethod | 106 @staticmethod |
107 def KillHost(build_type): | 107 def KillHost(build_type): |
108 logging.info('Killing host_forwarder.') | 108 logging.info('Killing host_forwarder.') |
109 host_forwarder_path = _MakeBinaryPath(build_type, 'host_forwarder') | 109 host_forwarder_path = _MakeBinaryPath(build_type, 'host_forwarder') |
| 110 assert os.path.exists(host_forwarder_path), 'Please build forwarder2' |
110 (exit_code, output) = cmd_helper.GetCmdStatusAndOutput( | 111 (exit_code, output) = cmd_helper.GetCmdStatusAndOutput( |
111 [host_forwarder_path, 'kill-server']) | 112 [host_forwarder_path, 'kill-server']) |
112 if exit_code != 0: | 113 if exit_code != 0: |
113 (exit_code, output) = cmd_helper.GetCmdStatusAndOutput( | 114 (exit_code, output) = cmd_helper.GetCmdStatusAndOutput( |
114 ['pkill', 'host_forwarder']) | 115 ['pkill', 'host_forwarder']) |
115 if exit_code != 0: | 116 if exit_code != 0: |
116 raise Exception('%s exited with %d:\n%s' % ( | 117 raise Exception('%s exited with %d:\n%s' % ( |
117 host_forwarder_path, exit_code, '\n'.join(output))) | 118 host_forwarder_path, exit_code, '\n'.join(output))) |
118 | 119 |
119 @staticmethod | 120 @staticmethod |
(...skipping 15 matching lines...) Expand all Loading... |
135 | 136 |
136 def DevicePortForHostPort(self, host_port): | 137 def DevicePortForHostPort(self, host_port): |
137 """Get the device port that corresponds to a given host port.""" | 138 """Get the device port that corresponds to a given host port.""" |
138 return self._host_to_device_port_map.get(host_port) | 139 return self._host_to_device_port_map.get(host_port) |
139 | 140 |
140 def Close(self): | 141 def Close(self): |
141 """Terminate the forwarder process.""" | 142 """Terminate the forwarder process.""" |
142 if self._device_process: | 143 if self._device_process: |
143 self._device_process.close() | 144 self._device_process.close() |
144 self._device_process = None | 145 self._device_process = None |
OLD | NEW |