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 | 5 |
6 from skypy.skyserver import SkyServer | 6 from skypy.skyserver import SkyServer |
7 import argparse | 7 import argparse |
8 import hashlib | 8 import hashlib |
9 import json | 9 import json |
10 import logging | 10 import logging |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 pids['sky_server_port']) | 119 pids['sky_server_port']) |
120 url = SkyServer.url_for_path(remote_sky_server_port, | 120 url = SkyServer.url_for_path(remote_sky_server_port, |
121 pids['sky_server_root'], args.url_or_path) | 121 pids['sky_server_root'], args.url_or_path) |
122 return _convert_to_sky_url(url) | 122 return _convert_to_sky_url(url) |
123 | 123 |
124 | 124 |
125 def dev_packages_root(build_dir): | 125 def dev_packages_root(build_dir): |
126 return os.path.join(build_dir, 'gen', 'dart-pkg', 'packages') | 126 return os.path.join(build_dir, 'gen', 'dart-pkg', 'packages') |
127 | 127 |
128 | 128 |
129 def ensure_assets_are_downloaded(build_dir): | |
130 sky_pkg_dir = os.path.join(build_dir, 'gen', 'dart-pkg', 'sky') | |
131 sky_pkg_lib_dir = os.path.join(sky_pkg_dir, 'lib') | |
132 sky_icons_dir = \ | |
133 os.path.join(sky_pkg_lib_dir, 'assets', 'material-design-icons') | |
134 if not os.path.isdir(sky_icons_dir): | |
135 logging.info('NOTE: sky/assets/material-design-icons missing, ' | |
136 'Running `download_material_design_icons` for you.') | |
137 subprocess.check_call( | |
138 [os.path.join(sky_pkg_lib_dir, 'download_material_design_icons')]) | |
139 | |
140 | |
141 class SetBuildDir(object): | 129 class SetBuildDir(object): |
142 def add_subparser(self, subparsers): | 130 def add_subparser(self, subparsers): |
143 start_parser = subparsers.add_parser('set_build_dir', | 131 start_parser = subparsers.add_parser('set_build_dir', |
144 help='force the build_dir to a particular value without starting Sky
') | 132 help='force the build_dir to a particular value without starting Sky
') |
145 start_parser.add_argument('build_dir', type=str) | 133 start_parser.add_argument('build_dir', type=str) |
146 start_parser.set_defaults(func=self.run) | 134 start_parser.set_defaults(func=self.run) |
147 | 135 |
148 def run(self, args, pids): | 136 def run(self, args, pids): |
149 pids['build_dir'] = os.path.abspath(args.build_dir) | 137 pids['build_dir'] = os.path.abspath(args.build_dir) |
150 | 138 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 pm_output = subprocess.check_output(pm_command) | 179 pm_output = subprocess.check_output(pm_command) |
192 # e.g. package:/data/app/org.chromium.mojo.shell-1/base.apk | 180 # e.g. package:/data/app/org.chromium.mojo.shell-1/base.apk |
193 return pm_output.split(':')[-1] | 181 return pm_output.split(':')[-1] |
194 | 182 |
195 def run(self, args, pids): | 183 def run(self, args, pids): |
196 apk_path = os.path.join(args.build_dir, 'apks', APK_NAME) | 184 apk_path = os.path.join(args.build_dir, 'apks', APK_NAME) |
197 if not os.path.exists(apk_path): | 185 if not os.path.exists(apk_path): |
198 print "'%s' does not exist?" % apk_path | 186 print "'%s' does not exist?" % apk_path |
199 return 2 | 187 return 2 |
200 | 188 |
201 ensure_assets_are_downloaded(args.build_dir) | |
202 | |
203 packages_root = dev_packages_root(args.build_dir) | 189 packages_root = dev_packages_root(args.build_dir) |
204 sky_server = self._sky_server_for_args(args, packages_root) | 190 sky_server = self._sky_server_for_args(args, packages_root) |
205 pids['sky_server_pid'] = sky_server.start() | 191 pids['sky_server_pid'] = sky_server.start() |
206 pids['sky_server_port'] = sky_server.port | 192 pids['sky_server_port'] = sky_server.port |
207 pids['sky_server_root'] = sky_server.root | 193 pids['sky_server_root'] = sky_server.root |
208 | 194 |
209 pids['build_dir'] = os.path.abspath(args.build_dir) | 195 pids['build_dir'] = os.path.abspath(args.build_dir) |
210 | 196 |
211 if args.install: | 197 if args.install: |
212 # We might need to install a new APK, so check SHA1 | 198 # We might need to install a new APK, so check SHA1 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 args = parser.parse_args() | 499 args = parser.parse_args() |
514 pids = Pids.read_from(PID_FILE_PATH, PID_FILE_KEYS) | 500 pids = Pids.read_from(PID_FILE_PATH, PID_FILE_KEYS) |
515 exit_code = args.func(args, pids) | 501 exit_code = args.func(args, pids) |
516 # We could do this with an at-exit handler instead? | 502 # We could do this with an at-exit handler instead? |
517 pids.write_to(PID_FILE_PATH) | 503 pids.write_to(PID_FILE_PATH) |
518 sys.exit(exit_code) | 504 sys.exit(exit_code) |
519 | 505 |
520 | 506 |
521 if __name__ == '__main__': | 507 if __name__ == '__main__': |
522 SkyShellRunner().main() | 508 SkyShellRunner().main() |
OLD | NEW |