| 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_directory(self, local_dir_path, port=0): | 9 def serve_local_directory(self, local_dir_path, port=0, free_host_port=False): |
| 10 """Serves the content of the local (host) directory, making it available to | 10 """Serves the content of the local (host) directory, making it available to |
| 11 the shell under the url returned by the function. | 11 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 local_dir_path: path to the directory to be served | 17 local_dir_path: path to the directory to be served |
| 18 port: port at which the server will be available to the shell | 18 port: port at which the server will be available to the shell. On Android |
| 19 this can be different from the port on which the server runs on the |
| 20 host. |
| 21 free_host_port: spawn the server a system allocated port. This is ignored |
| 22 on Linux, where |port| indicates the port on which the server will be |
| 23 spawned. |
| 19 | 24 |
| 20 Returns: | 25 Returns: |
| 21 The url that the shell can use to access the content of |local_dir_path|. | 26 The url that the shell can use to access the content of |local_dir_path|. |
| 22 """ | 27 """ |
| 23 raise NotImplementedError() | 28 raise NotImplementedError() |
| 24 | 29 |
| 25 def serve_local_directories(self, mappings, port=0): | 30 def serve_local_directories(self, mappings, port=0, free_host_port=False): |
| 26 """Serves the content of the local (host) directories, making it available | 31 """Serves the content of the local (host) directories, making it available |
| 27 to the shell under the url returned by the function. | 32 to the shell under the url returned by the function. |
| 28 | 33 |
| 29 The server will run on a separate thread until the program terminates. The | 34 The server will run on a separate thread until the program terminates. The |
| 30 call returns immediately. | 35 call returns immediately. |
| 31 | 36 |
| 32 Args: | 37 Args: |
| 33 mappings: List of tuples (prefix, local_base_path_list) mapping URLs that | 38 mappings: List of tuples (prefix, local_base_path_list) mapping URLs that |
| 34 start with |prefix| to one or more local directories enumerated in | 39 start with |prefix| to one or more local directories enumerated in |
| 35 |local_base_path_list|. The prefixes should skip the leading slash. | 40 |local_base_path_list|. The prefixes should skip the leading slash. |
| 36 The first matching prefix and the first location that contains the | 41 The first matching prefix and the first location that contains the |
| 37 requested file will be used each time. | 42 requested file will be used each time. |
| 38 port: port at which the server will be available to the shell | 43 port: port at which the server will be available to the shell. On Android |
| 44 this can be different from the port on which the server runs on the |
| 45 host. |
| 46 free_host_port: spawn the server a system allocated port. This is ignored |
| 47 on Linux, where |port| indicates the port on which the server will be |
| 48 spawned. |
| 39 | 49 |
| 40 Returns: | 50 Returns: |
| 41 The url that the shell can use to access the server. | 51 The url that the shell can use to access the server. |
| 42 """ | 52 """ |
| 43 raise NotImplementedError() | 53 raise NotImplementedError() |
| 44 | 54 |
| 45 def forward_host_port_to_shell(self, host_port): | 55 def forward_host_port_to_shell(self, host_port): |
| 46 """Forwards a port on the host machine to the same port wherever the shell | 56 """Forwards a port on the host machine to the same port wherever the shell |
| 47 is running. | 57 is running. |
| 48 | 58 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 70 terminated | 80 terminated |
| 71 | 81 |
| 72 Returns: | 82 Returns: |
| 73 A tuple of (return_code, output, did_time_out). |return_code| is the exit | 83 A tuple of (return_code, output, did_time_out). |return_code| is the exit |
| 74 code returned by the shell or None if the exit code cannot be retrieved. | 84 code returned by the shell or None if the exit code cannot be retrieved. |
| 75 |output| is the stdout mingled with the stderr produced by the shell. | 85 |output| is the stdout mingled with the stderr produced by the shell. |
| 76 |did_time_out| is True iff the shell was terminated because it exceeded | 86 |did_time_out| is True iff the shell was terminated because it exceeded |
| 77 the |timeout| and False otherwise. | 87 the |timeout| and False otherwise. |
| 78 """ | 88 """ |
| 79 raise NotImplementedError() | 89 raise NotImplementedError() |
| OLD | NEW |