| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 if os.path.commonprefix([path, SRC_ROOT]) == SRC_ROOT: | 167 if os.path.commonprefix([path, SRC_ROOT]) == SRC_ROOT: |
| 168 server_root = SRC_ROOT | 168 server_root = SRC_ROOT |
| 169 else: | 169 else: |
| 170 server_root = os.path.dirname(path) | 170 server_root = os.path.dirname(path) |
| 171 logging.warn( | 171 logging.warn( |
| 172 '%s is outside of mojo root, using %s as server root' % | 172 '%s is outside of mojo root, using %s as server root' % |
| 173 (path, server_root)) | 173 (path, server_root)) |
| 174 return server_root | 174 return server_root |
| 175 | 175 |
| 176 def _sky_server_for_args(self, args, packages_root): | 176 def _sky_server_for_args(self, args, packages_root): |
| 177 # FIXME: This is a hack. sky_server should just take a build_dir | |
| 178 # not a magical "configuration" name. | |
| 179 configuration = os.path.basename(os.path.normpath(args.build_dir)) | |
| 180 server_root = self._server_root_for_url(args.url_or_path) | 177 server_root = self._server_root_for_url(args.url_or_path) |
| 181 sky_server = SkyServer(SKY_SERVER_PORT, configuration, server_root, pack
ages_root) | 178 sky_server = SkyServer(SKY_SERVER_PORT, server_root, packages_root) |
| 182 return sky_server | 179 return sky_server |
| 183 | 180 |
| 184 def _find_remote_pid_for_package(self, package): | 181 def _find_remote_pid_for_package(self, package): |
| 185 ps_output = subprocess.check_output([ADB_PATH, 'shell', 'ps']) | 182 ps_output = subprocess.check_output([ADB_PATH, 'shell', 'ps']) |
| 186 for line in ps_output.split('\n'): | 183 for line in ps_output.split('\n'): |
| 187 fields = line.split() | 184 fields = line.split() |
| 188 if fields and fields[-1] == package: | 185 if fields and fields[-1] == package: |
| 189 return fields[1] | 186 return fields[1] |
| 190 return None | 187 return None |
| 191 | 188 |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 args = parser.parse_args() | 513 args = parser.parse_args() |
| 517 pids = Pids.read_from(PID_FILE_PATH, PID_FILE_KEYS) | 514 pids = Pids.read_from(PID_FILE_PATH, PID_FILE_KEYS) |
| 518 exit_code = args.func(args, pids) | 515 exit_code = args.func(args, pids) |
| 519 # We could do this with an at-exit handler instead? | 516 # We could do this with an at-exit handler instead? |
| 520 pids.write_to(PID_FILE_PATH) | 517 pids.write_to(PID_FILE_PATH) |
| 521 sys.exit(exit_code) | 518 sys.exit(exit_code) |
| 522 | 519 |
| 523 | 520 |
| 524 if __name__ == '__main__': | 521 if __name__ == '__main__': |
| 525 SkyShellRunner().main() | 522 SkyShellRunner().main() |
| OLD | NEW |