Chromium Code Reviews| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 | 55 |
| 56 adb = android_commands.AndroidCommands(options.device) | 56 adb = android_commands.AndroidCommands(options.device) |
| 57 tool = CreateTool(None, adb) | 57 tool = CreateTool(None, adb) |
| 58 forwarder_instance = forwarder.Forwarder(adb, options.build_type) | 58 forwarder_instance = forwarder.Forwarder(adb, options.build_type) |
| 59 try: | 59 try: |
| 60 forwarder_instance.Run(port_pairs, tool, options.host) | 60 forwarder_instance.Run(port_pairs, tool, options.host) |
| 61 while True: | 61 while True: |
| 62 time.sleep(60) | 62 time.sleep(60) |
| 63 except KeyboardInterrupt: | 63 except KeyboardInterrupt: |
| 64 sys.exit(0) | 64 sys.exit(0) |
| 65 except OSError as e: | |
| 66 if e.errno == 2: | |
| 67 print 'Unable to start. Make sure you have built host_forwarder.' | |
|
bulach
2013/03/08 15:15:33
maybe push this down to forwarder.py Run itself?
| |
| 68 sys.exit(1) | |
| 69 else: raise | |
| 65 finally: | 70 finally: |
| 66 forwarder_instance.Close() | 71 forwarder_instance.Close() |
| 67 | 72 |
| 68 | 73 |
| 69 if __name__ == '__main__': | 74 if __name__ == '__main__': |
| 70 main(sys.argv) | 75 main(sys.argv) |
| OLD | NEW |