| 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 ServeLocalDirectory(self, local_dir_path, port=0): | 9 def ServeLocalDirectory(self, local_dir_path, port=0): |
| 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 |
| 19 | 19 |
| 20 Returns: | 20 Returns: |
| 21 The url that the shell can use to access the content of |local_dir_path|. | 21 The url that the shell can use to access the content of |local_dir_path|. |
| 22 """ | 22 """ |
| 23 raise NotImplementedError() | 23 raise NotImplementedError() |
| 24 | 24 |
| 25 def ForwardHostPortToShell(self, host_port): |
| 26 """Forwards a port on the host machine to the same port wherever the shell |
| 27 is running. |
| 28 |
| 29 This is a no-op if the shell is running locally. |
| 30 """ |
| 31 raise NotImplementedError() |
| 32 |
| 25 def Run(self, arguments): | 33 def Run(self, arguments): |
| 26 """Runs the shell with given arguments until shell exits, passing the stdout | 34 """Runs the shell with given arguments until shell exits, passing the stdout |
| 27 mingled with stderr produced by the shell onto the stdout. | 35 mingled with stderr produced by the shell onto the stdout. |
| 28 | 36 |
| 29 Returns: | 37 Returns: |
| 30 Exit code retured by the shell or None if the exit code cannot be | 38 Exit code retured by the shell or None if the exit code cannot be |
| 31 retrieved. | 39 retrieved. |
| 32 """ | 40 """ |
| 33 raise NotImplementedError() | 41 raise NotImplementedError() |
| 34 | 42 |
| 35 def RunAndGetOutput(self, arguments): | 43 def RunAndGetOutput(self, arguments): |
| 36 """Runs the shell with given arguments until shell exits and returns the | 44 """Runs the shell with given arguments until shell exits and returns the |
| 37 output. | 45 output. |
| 38 | 46 |
| 39 Args: | 47 Args: |
| 40 arguments: list of arguments for the shell | 48 arguments: list of arguments for the shell |
| 41 | 49 |
| 42 Returns: | 50 Returns: |
| 43 A tuple of (return_code, output). |return_code| is the exit code returned | 51 A tuple of (return_code, output). |return_code| is the exit code returned |
| 44 by the shell or None if the exit code cannot be retrieved. |output| is the | 52 by the shell or None if the exit code cannot be retrieved. |output| is the |
| 45 stdout mingled with the stderr produced by the shell. | 53 stdout mingled with the stderr produced by the shell. |
| 46 """ | 54 """ |
| 47 raise NotImplementedError() | 55 raise NotImplementedError() |
| OLD | NEW |