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

Side by Side Diff: mojo/devtools/common/devtoolslib/shell_arguments.py

Issue 1268713005: Unify method name casing in devtools. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
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 """Produces configured shell abstractions. 5 """Produces configured shell abstractions.
6 6
7 This module knows how to produce a configured shell abstraction based on 7 This module knows how to produce a configured shell abstraction based on
8 shell_config.ShellConfig. 8 shell_config.ShellConfig.
9 """ 9 """
10 10
(...skipping 22 matching lines...) Expand all
33 def _host_local_url_destination(shell, dest_file, port): 33 def _host_local_url_destination(shell, dest_file, port):
34 """Starts a local server to host |dest_file|. 34 """Starts a local server to host |dest_file|.
35 35
36 Returns: 36 Returns:
37 Url of the hosted file. 37 Url of the hosted file.
38 """ 38 """
39 directory = os.path.dirname(dest_file) 39 directory = os.path.dirname(dest_file)
40 if not os.path.exists(directory): 40 if not os.path.exists(directory):
41 raise ValueError('local path passed as --map-url destination ' 41 raise ValueError('local path passed as --map-url destination '
42 'does not exist') 42 'does not exist')
43 server_url = shell.ServeLocalDirectory(directory, port) 43 server_url = shell.serve_local_directory(directory, port)
44 return server_url + os.path.relpath(dest_file, directory) 44 return server_url + os.path.relpath(dest_file, directory)
45 45
46 46
47 def _host_local_origin_destination(shell, dest_dir, port): 47 def _host_local_origin_destination(shell, dest_dir, port):
48 """Starts a local server to host |dest_dir|. 48 """Starts a local server to host |dest_dir|.
49 49
50 Returns: 50 Returns:
51 Url of the hosted directory. 51 Url of the hosted directory.
52 """ 52 """
53 return shell.ServeLocalDirectory(dest_dir, port) 53 return shell.serve_local_directory(dest_dir, port)
54 54
55 55
56 def _rewrite(mapping, host_destination_functon, shell, port): 56 def _rewrite(mapping, host_destination_functon, shell, port):
57 """Takes a mapping given as <src>=<dest> and rewrites the <dest> part to be 57 """Takes a mapping given as <src>=<dest> and rewrites the <dest> part to be
58 hosted locally using the given function if <dest> is not a web url. 58 hosted locally using the given function if <dest> is not a web url.
59 """ 59 """
60 parts = mapping.split('=') 60 parts = mapping.split('=')
61 if len(parts) != 2: 61 if len(parts) != 2:
62 raise ValueError('each mapping value should be in format ' 62 raise ValueError('each mapping value should be in format '
63 '"<url>=<url-or-local-path>"') 63 '"<url>=<url-or-local-path>"')
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 129
130 def configure_local_origin(shell, local_dir, fixed_port=True): 130 def configure_local_origin(shell, local_dir, fixed_port=True):
131 """Sets up a local http server to serve files in |local_dir| along with 131 """Sets up a local http server to serve files in |local_dir| along with
132 device port forwarding if needed. 132 device port forwarding if needed.
133 133
134 Returns: 134 Returns:
135 The list of arguments to be appended to the shell argument list. 135 The list of arguments to be appended to the shell argument list.
136 """ 136 """
137 137
138 origin_url = shell.ServeLocalDirectory( 138 origin_url = shell.serve_local_directory(
139 local_dir, _LOCAL_ORIGIN_PORT if fixed_port else 0) 139 local_dir, _LOCAL_ORIGIN_PORT if fixed_port else 0)
140 return ["--origin=" + origin_url] 140 return ["--origin=" + origin_url]
141 141
142 142
143 def append_to_argument(arguments, key, value, delimiter=","): 143 def append_to_argument(arguments, key, value, delimiter=","):
144 """Looks for an argument of the form "key=val1,val2" within |arguments| and 144 """Looks for an argument of the form "key=val1,val2" within |arguments| and
145 appends |value| to it. 145 appends |value| to it.
146 146
147 If the argument is not present in |arguments| it is added. 147 If the argument is not present in |arguments| it is added.
148 148
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 Throws: 188 Throws:
189 ShellConfigurationException if shell abstraction could not be configured. 189 ShellConfigurationException if shell abstraction could not be configured.
190 """ 190 """
191 if shell_config.android: 191 if shell_config.android:
192 verbose_pipe = sys.stdout if shell_config.verbose else None 192 verbose_pipe = sys.stdout if shell_config.verbose else None
193 193
194 shell = AndroidShell(shell_config.adb_path, shell_config.target_device, 194 shell = AndroidShell(shell_config.adb_path, shell_config.target_device,
195 logcat_tags=shell_config.logcat_tags, 195 logcat_tags=shell_config.logcat_tags,
196 verbose_pipe=verbose_pipe) 196 verbose_pipe=verbose_pipe)
197 197
198 device_status, error = shell.CheckDevice() 198 device_status, error = shell.check_device()
199 if not device_status: 199 if not device_status:
200 raise ShellConfigurationException('Device check failed: ' + error) 200 raise ShellConfigurationException('Device check failed: ' + error)
201 if shell_config.shell_path: 201 if shell_config.shell_path:
202 shell.InstallApk(shell_config.shell_path) 202 shell.install_apk(shell_config.shell_path)
203 else: 203 else:
204 if not shell_config.shell_path: 204 if not shell_config.shell_path:
205 raise ShellConfigurationException('Can not run without a shell binary. ' 205 raise ShellConfigurationException('Can not run without a shell binary. '
206 'Please pass --shell-path.') 206 'Please pass --shell-path.')
207 shell = LinuxShell(shell_config.shell_path) 207 shell = LinuxShell(shell_config.shell_path)
208 if shell_config.use_osmesa: 208 if shell_config.use_osmesa:
209 shell_args.append('--args-for=mojo:native_viewport_service --use-osmesa') 209 shell_args.append('--args-for=mojo:native_viewport_service --use-osmesa')
210 210
211 shell_args = _apply_mappings(shell, shell_args, shell_config.map_url_list, 211 shell_args = _apply_mappings(shell, shell_args, shell_config.map_url_list,
212 shell_config.map_origin_list) 212 shell_config.map_origin_list)
213 213
214 if shell_config.origin: 214 if shell_config.origin:
215 if _is_web_url(shell_config.origin): 215 if _is_web_url(shell_config.origin):
216 shell_args.append('--origin=' + shell_config.origin) 216 shell_args.append('--origin=' + shell_config.origin)
217 else: 217 else:
218 shell_args.extend(configure_local_origin(shell, shell_config.origin, 218 shell_args.extend(configure_local_origin(shell, shell_config.origin,
219 fixed_port=True)) 219 fixed_port=True))
220 220
221 if shell_config.sky: 221 if shell_config.sky:
222 shell_args = _configure_sky(shell_args) 222 shell_args = _configure_sky(shell_args)
223 223
224 return shell, shell_args 224 return shell, shell_args
OLDNEW
« no previous file with comments | « mojo/devtools/common/devtoolslib/shell.py ('k') | mojo/devtools/common/devtoolslib/shell_arguments_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698