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

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

Issue 1259793008: Support dev servers defined in a mojoconfig file. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Address Ben's comments. Created 5 years, 4 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 | « mojo/devtools/common/devtoolslib/http_server.py ('k') | mojo/devtools/common/devtoolslib/shell_config.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/devtools/common/devtoolslib/shell_arguments.py
diff --git a/mojo/devtools/common/devtoolslib/shell_arguments.py b/mojo/devtools/common/devtoolslib/shell_arguments.py
index 89d66e41ce8075bd389215b9469359030034620d..bd1375554b5ca44edf00d196b3254e64ac86488d 100644
--- a/mojo/devtools/common/devtoolslib/shell_arguments.py
+++ b/mojo/devtools/common/devtoolslib/shell_arguments.py
@@ -14,6 +14,7 @@ import urlparse
from devtoolslib.android_shell import AndroidShell
from devtoolslib.linux_shell import LinuxShell
+from devtoolslib.shell_config import ShellConfigurationException
# When spinning up servers for local origins, we want to use predictable ports
# so that caching works between subsequent runs with the same command line.
@@ -21,11 +22,6 @@ _LOCAL_ORIGIN_PORT = 31840
_MAPPINGS_BASE_PORT = 31841
-class ShellConfigurationException(Exception):
- """Represents an error preventing creating a functional shell abstraction."""
- pass
-
-
def _is_web_url(dest):
return True if urlparse.urlparse(dest).scheme else False
@@ -170,6 +166,26 @@ def append_to_argument(arguments, key, value, delimiter=","):
return arguments
+def _configure_dev_server(shell, shell_args, dev_server_config):
+ """Sets up a dev server on the host according to |dev_server_config|.
+
+ Args:
+ shell: The shell that is being configured.
+ shell_arguments: Current list of shell arguments.
+ dev_server_config: Instance of shell_config.DevServerConfig describing the
+ dev server to be set up.
+
+ Returns:
+ The updated argument list.
+ """
+ server_url = shell.serve_local_directories(dev_server_config.mappings)
+ shell_args.append('--map-origin=%s=%s' % (dev_server_config.host, server_url))
+ print "Configured %s locally as %s" % (dev_server_config.host, server_url)
+ for mapping_prefix, mapping_path in dev_server_config.mappings:
+ print " /%s -> %s" % (mapping_prefix, mapping_path)
+ return shell_args
+
+
def get_shell(shell_config, shell_args):
"""
Produces a shell abstraction configured according to |shell_config|.
@@ -221,4 +237,7 @@ def get_shell(shell_config, shell_args):
if shell_config.sky:
shell_args = _configure_sky(shell_args)
+ for dev_server_config in shell_config.dev_servers:
+ shell_args = _configure_dev_server(shell, shell_args, dev_server_config)
+
return shell, shell_args
« no previous file with comments | « mojo/devtools/common/devtoolslib/http_server.py ('k') | mojo/devtools/common/devtoolslib/shell_config.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698