Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Unified Diff: mojo/devtools/common/devtoolslib/android_shell.py

Issue 1139053005: Add ServeLocalDirectory to the shell abstraction. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | mojo/devtools/common/devtoolslib/http_server.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/devtools/common/devtoolslib/android_shell.py
diff --git a/mojo/devtools/common/devtoolslib/android_shell.py b/mojo/devtools/common/devtoolslib/android_shell.py
index 4bae3de4449c5de79b7ba20bcd41a67d3d93a756..80c87ceaaa1271fbf29595a69a11343234fda336 100644
--- a/mojo/devtools/common/devtoolslib/android_shell.py
+++ b/mojo/devtools/common/devtoolslib/android_shell.py
@@ -142,7 +142,7 @@ class AndroidShell(Shell):
atexit.register(_UnmapPort)
return device_port
- def _StartHttpServerForDirectory(self, path, port=0):
+ def _StartHttpServerForDirectory(self, path, device_port=0):
"""Starts an http server serving files from |path|. Returns the local
url.
"""
@@ -151,7 +151,8 @@ class AndroidShell(Shell):
server_address = StartHttpServer(path)
print 'local port=%d' % server_address[1]
- return 'http://127.0.0.1:%d/' % self._MapPort(port, server_address[1])
+ return 'http://127.0.0.1:%d/' % self._MapPort(device_port,
+ server_address[1])
def _StartHttpServerForOriginMapping(self, mapping, port):
"""If |mapping| points at a local file starts an http server to serve files
@@ -223,6 +224,19 @@ class AndroidShell(Shell):
local_dir, DEFAULT_BASE_PORT if fixed_port else 0)
return "--origin=" + origin_url
+ def ServeLocalDirectory(self, local_dir_path, port=0):
+ """Serves the content of the local (host) directory, making it available to
+ the shell under the url returned by the function.
+
+ The server will run on a separate thread until the program terminates. The
+ call returns immediately.
+
+ Args:
+ local_dir_path: path to the directory to be served
+ port: port at which the server will be available to the shell
+ """
+ return self._StartHttpServerForDirectory(local_dir_path, port)
qsr 2015/05/19 13:55:42 You are just delegatng to a private method -> you
ppi 2015/05/19 14:22:48 Done.
+
def StartShell(self,
arguments,
stdout=None,
« no previous file with comments | « no previous file | mojo/devtools/common/devtoolslib/http_server.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698