| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 | 5 |
| 6 class Shell(object): | 6 class Shell(object): |
| 7 """Represents an abstract Mojo shell.""" | 7 """Represents an abstract Mojo shell.""" |
| 8 | 8 |
| 9 def serve_local_directories(self, mappings, port=0, free_host_port=False): | 9 def serve_local_directories(self, mappings, port=0, reuse_servers=False): |
| 10 """Serves the content of the local (host) directories, making it available | 10 """Serves the content of the local (host) directories, making it available |
| 11 to the shell under the url returned by the function. | 11 to the shell under the url returned by the function. |
| 12 | 12 |
| 13 The server will run on a separate thread until the program terminates. The | 13 The server will run on a separate thread until the program terminates. The |
| 14 call returns immediately. | 14 call returns immediately. |
| 15 | 15 |
| 16 Args: | 16 Args: |
| 17 mappings: List of tuples (prefix, local_base_path_list) mapping URLs that | 17 mappings: List of tuples (prefix, local_base_path_list) mapping URLs that |
| 18 start with |prefix| to one or more local directories enumerated in | 18 start with |prefix| to one or more local directories enumerated in |
| 19 |local_base_path_list|. The prefixes should skip the leading slash. | 19 |local_base_path_list|. The prefixes should skip the leading slash. |
| 20 The first matching prefix and the first location that contains the | 20 The first matching prefix and the first location that contains the |
| 21 requested file will be used each time. | 21 requested file will be used each time. |
| 22 port: port at which the server will be available to the shell. On Android | 22 port: port at which the server will be available to the shell. On Android |
| 23 this can be different from the port on which the server runs on the | 23 this can be different from the port on which the server runs on the |
| 24 host. | 24 host. |
| 25 free_host_port: spawn the server a system allocated port. This is ignored | 25 reuse_servers: don't actually spawn the server. Instead assume that the |
| 26 on Linux, where |port| indicates the port on which the server will be | 26 server is already running on |port|, and only set up forwarding if |
| 27 spawned. | 27 needed. |
| 28 | 28 |
| 29 Returns: | 29 Returns: |
| 30 The url that the shell can use to access the server. | 30 The url that the shell can use to access the server. |
| 31 """ | 31 """ |
| 32 raise NotImplementedError() | 32 raise NotImplementedError() |
| 33 | 33 |
| 34 def forward_host_port_to_shell(self, host_port): | 34 def forward_host_port_to_shell(self, host_port): |
| 35 """Forwards a port on the host machine to the same port wherever the shell | 35 """Forwards a port on the host machine to the same port wherever the shell |
| 36 is running. | 36 is running. |
| 37 | 37 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 59 terminated | 59 terminated |
| 60 | 60 |
| 61 Returns: | 61 Returns: |
| 62 A tuple of (return_code, output, did_time_out). |return_code| is the exit | 62 A tuple of (return_code, output, did_time_out). |return_code| is the exit |
| 63 code returned by the shell or None if the exit code cannot be retrieved. | 63 code returned by the shell or None if the exit code cannot be retrieved. |
| 64 |output| is the stdout mingled with the stderr produced by the shell. | 64 |output| is the stdout mingled with the stderr produced by the shell. |
| 65 |did_time_out| is True iff the shell was terminated because it exceeded | 65 |did_time_out| is True iff the shell was terminated because it exceeded |
| 66 the |timeout| and False otherwise. | 66 the |timeout| and False otherwise. |
| 67 """ | 67 """ |
| 68 raise NotImplementedError() | 68 raise NotImplementedError() |
| OLD | NEW |