Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 # | |
| 6 # The script follows mojo/services/html_viewer/view_url.py and modified it for | |
| 7 # test the mojo media renderer. The page will be rendered in a windowless mode. | |
| 8 # | |
| 9 # TODO(xhwang): Explore the possibility of running this with the Kiosk window | |
| 10 # manager. | |
| 5 | 11 |
| 6 import argparse | 12 import argparse |
| 7 import os | 13 import os |
| 8 import subprocess | 14 import subprocess |
| 9 import sys | 15 import sys |
| 10 | 16 |
| 11 root_path = os.path.realpath( | 17 root_path = os.path.realpath( |
| 12 os.path.join( | 18 os.path.join( |
| 13 os.path.dirname( | 19 os.path.dirname( |
| 14 os.path.realpath(__file__)), | 20 os.path.realpath(__file__)), |
| 15 os.pardir, | 21 os.pardir, |
| 16 os.pardir, | 22 os.pardir, |
| 17 os.pardir)) | 23 os.pardir)) |
| 18 | 24 |
| 19 def _BuildShellCommand(args): | 25 def _BuildShellCommand(args): |
| 20 sdk_version = subprocess.check_output(["cat", | 26 sdk_version = subprocess.check_output(["cat", |
| 21 "third_party/mojo/src/mojo/public/VERSION"], cwd=root_path) | 27 "third_party/mojo/src/mojo/public/VERSION"], cwd=root_path) |
| 22 build_dir = os.path.join(root_path, args.build_dir) | 28 build_dir = os.path.join(root_path, args.build_dir) |
| 23 | 29 |
| 24 shell_command = [os.path.join(build_dir, "mojo_shell")] | 30 shell_command = [os.path.join(build_dir, "mojo_shell")] |
| 25 | 31 |
| 26 options = [] | 32 options = [] |
| 27 options.append( | 33 options.append( |
| 28 "--origin=https://storage.googleapis.com/mojo/services/linux-x64/%s" % | 34 "--origin=https://storage.googleapis.com/mojo/services/linux-x64/%s" % |
| 29 sdk_version) | 35 sdk_version) |
| 30 options.append("--url-mappings=mojo:html_viewer=file://%s/html_viewer.mojo" % | 36 options.append("--url-mappings=mojo:html_viewer=file://%s/html_viewer.mojo," |
| 31 build_dir) | 37 "mojo:media=file://%s/media.mojo" % (build_dir, build_dir)) |
| 32 options.append('--args-for=mojo:kiosk_wm %s' % args.url) | 38 args_for_html_viewer = "--enable-mojo-media-renderer " |
| 39 if args.verbose: | |
| 40 args_for_html_viewer += \ | |
| 41 "--vmodule=pipeline*=3,*renderer_impl*=3,*mojo_demuxer*=3" | |
| 42 options.append("--args-for=mojo:html_viewer %s" % args_for_html_viewer) | |
| 33 | 43 |
| 34 app_to_run = "mojo:kiosk_wm" | 44 full_command = shell_command + options + [args.url] |
| 35 | 45 |
| 36 return shell_command + options + [app_to_run] | 46 if args.verbose: |
| 47 print full_command | |
| 48 | |
| 49 return full_command | |
| 37 | 50 |
| 38 def main(): | 51 def main(): |
| 39 parser = argparse.ArgumentParser( | 52 parser = argparse.ArgumentParser( |
| 40 description="View a URL with HTMLViewer in the Kiosk window manager. " | 53 description="View a URL with HTMLViewer with mojo media renderer. " |
| 41 "You must have built //mojo/services/html_viewer and " | 54 "You must have built //mojo/services/html_viewer, " |
| 42 "//mojo/services/network first. Note that this will " | 55 "//mojo/services/network and //media/mojo/services first. " |
| 43 "currently often fail spectacularly due to lack of binary " | 56 " Note that this will currently often fail spectacularly due " |
| 44 "stability in Mojo.") | 57 " to lack of binary stability in Mojo.") |
| 45 parser.add_argument( | 58 parser.add_argument( |
| 46 "--build-dir", | 59 "--build-dir", |
| 47 help="Path to the dir containing the linux-x64 binaries relative to the " | 60 help="Path to the dir containing the linux-x64 binaries relative to the " |
| 48 "repo root (default: %(default)s)", | 61 "repo root (default: %(default)s)", |
| 49 default="out/Release") | 62 default="out/Release") |
| 63 parser.add_argument("--verbose", help="Increase output verbosity.", | |
| 64 action="store_true") | |
|
DaleCurtis
2015/03/09 20:09:44
default=False? I forget if you need that.
xhwang
2015/03/09 20:18:40
I am still learning argparse so I am not sure eith
| |
| 50 parser.add_argument("url", | 65 parser.add_argument("url", |
| 51 help="The URL to be viewed") | 66 help="The URL to be viewed") |
| 52 | 67 |
| 53 args = parser.parse_args() | 68 args = parser.parse_args() |
| 54 return subprocess.call(_BuildShellCommand(args)) | 69 return subprocess.call(_BuildShellCommand(args)) |
| 55 | 70 |
| 56 if __name__ == '__main__': | 71 if __name__ == '__main__': |
| 57 sys.exit(main()) | 72 sys.exit(main()) |
| OLD | NEW |