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| |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 try: | 54 try: |
55 port_pairs = [int(a) for a in args[1:]] | 55 port_pairs = [int(a) for a in args[1:]] |
56 port_pairs = zip(port_pairs[::2], port_pairs[1::2]) | 56 port_pairs = zip(port_pairs[::2], port_pairs[1::2]) |
57 except ValueError: | 57 except ValueError: |
58 parser.error('Bad port number') | 58 parser.error('Bad port number') |
59 sys.exit(1) | 59 sys.exit(1) |
60 | 60 |
61 blacklist = (device_blacklist.Blacklist(options.blacklist_file) | 61 blacklist = (device_blacklist.Blacklist(options.blacklist_file) |
62 if options.blacklist_file | 62 if options.blacklist_file |
63 else None) | 63 else None) |
64 device = device_utils.DeviceUtils.HealthyDevices(blacklist=blacklist, | 64 device = device_utils.DeviceUtils.HealthyDevices( |
65 device_arg=options.device) | 65 blacklist=blacklist, device_arg=options.device)[0] |
66 constants.SetBuildType(options.build_type) | 66 constants.SetBuildType(options.build_type) |
67 try: | 67 try: |
68 forwarder.Forwarder.Map(port_pairs, device) | 68 forwarder.Forwarder.Map(port_pairs, device) |
69 while True: | 69 while True: |
70 time.sleep(60) | 70 time.sleep(60) |
71 except KeyboardInterrupt: | 71 except KeyboardInterrupt: |
72 sys.exit(0) | 72 sys.exit(0) |
73 finally: | 73 finally: |
74 forwarder.Forwarder.UnmapAllDevicePorts(device) | 74 forwarder.Forwarder.UnmapAllDevicePorts(device) |
75 | 75 |
76 if __name__ == '__main__': | 76 if __name__ == '__main__': |
77 main(sys.argv) | 77 main(sys.argv) |
OLD | NEW |