OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """Command line tool for forwarding ports from a device to the host. | 7 """Command line tool for forwarding ports from a device to the host. |
8 | 8 |
9 Allows an Android device to connect to services running on the host machine, | 9 Allows an Android device to connect to services running on the host machine, |
10 i.e., "adb forward" in reverse. Requires |host_forwarder| and |device_forwarder| | 10 i.e., "adb forward" in reverse. Requires |host_forwarder| and |device_forwarder| |
11 to be built. | 11 to be built. |
12 """ | 12 """ |
13 | 13 |
14 import logging | 14 import logging |
15 import optparse | 15 import optparse |
16 import sys | 16 import sys |
17 import time | 17 import time |
18 | 18 |
| 19 from devil.android import device_blacklist |
| 20 from devil.android import device_errors |
| 21 from devil.android import device_utils |
| 22 from devil.android.sdk import adb_wrapper |
| 23 from devil.utils import run_tests_helper |
19 from pylib import constants | 24 from pylib import constants |
20 from pylib import forwarder | 25 from pylib import forwarder |
21 from pylib.device import adb_wrapper | |
22 from pylib.device import device_blacklist | |
23 from pylib.device import device_errors | |
24 from pylib.device import device_utils | |
25 from pylib.utils import run_tests_helper | |
26 | 26 |
27 | 27 |
28 def main(argv): | 28 def main(argv): |
29 parser = optparse.OptionParser(usage='Usage: %prog [options] device_port ' | 29 parser = optparse.OptionParser(usage='Usage: %prog [options] device_port ' |
30 'host_port [device_port_2 host_port_2] ...', | 30 'host_port [device_port_2 host_port_2] ...', |
31 description=__doc__) | 31 description=__doc__) |
32 parser.add_option('-v', | 32 parser.add_option('-v', |
33 '--verbose', | 33 '--verbose', |
34 dest='verbose_count', | 34 dest='verbose_count', |
35 default=0, | 35 default=0, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 forwarder.Forwarder.Map(port_pairs, device) | 78 forwarder.Forwarder.Map(port_pairs, device) |
79 while True: | 79 while True: |
80 time.sleep(60) | 80 time.sleep(60) |
81 except KeyboardInterrupt: | 81 except KeyboardInterrupt: |
82 sys.exit(0) | 82 sys.exit(0) |
83 finally: | 83 finally: |
84 forwarder.Forwarder.UnmapAllDevicePorts(device) | 84 forwarder.Forwarder.UnmapAllDevicePorts(device) |
85 | 85 |
86 if __name__ == '__main__': | 86 if __name__ == '__main__': |
87 main(sys.argv) | 87 main(sys.argv) |
OLD | NEW |