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

Side by Side Diff: sky/sdk/lib/sky_tool

Issue 1215103006: Improve default behavior for sky_tool start (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import argparse 6 import argparse
7 import json 7 import json
8 import logging 8 import logging
9 import os 9 import os
10 import re 10 import re
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 relative_path = os.path.relpath(path, root) 113 relative_path = os.path.relpath(path, root)
114 return 'sky://localhost:%s/%s' % (port, relative_path) 114 return 'sky://localhost:%s/%s' % (port, relative_path)
115 115
116 116
117 class StartSky(object): 117 class StartSky(object):
118 def add_subparser(self, subparsers): 118 def add_subparser(self, subparsers):
119 start_parser = subparsers.add_parser('start', 119 start_parser = subparsers.add_parser('start',
120 help='launch %s on the device' % APK_NAME) 120 help='launch %s on the device' % APK_NAME)
121 start_parser.add_argument('--install', action='store_true') 121 start_parser.add_argument('--install', action='store_true')
122 start_parser.add_argument('project_or_path', nargs='?', type=str, 122 start_parser.add_argument('project_or_path', nargs='?', type=str,
123 default='main.dart') 123 default='.')
124 start_parser.set_defaults(func=self.run) 124 start_parser.set_defaults(func=self.run)
125 125
126 def _is_package_installed(self, package_name): 126 def _is_package_installed(self, package_name):
127 pm_path_cmd = [ADB_PATH, 'shell', 'pm', 'path', package_name] 127 pm_path_cmd = [ADB_PATH, 'shell', 'pm', 'path', package_name]
128 return subprocess.check_output(pm_path_cmd).strip() != '' 128 return subprocess.check_output(pm_path_cmd).strip() != ''
129 129
130 def run(self, args, pids): 130 def run(self, args, pids):
131 StopSky().run(args, pids) 131 StopSky().run(args, pids)
132 132
133 project_or_path = os.path.abspath(args.project_or_path) 133 project_or_path = os.path.abspath(args.project_or_path)
134 134
135 if os.path.isdir(project_or_path): 135 if os.path.isdir(project_or_path):
136 sky_server_root = project_or_path 136 sky_server_root = project_or_path
137 main_dart = os.path.join(project_or_path, 'main.dart') 137 main_dart = os.path.join(project_or_path, 'lib', 'main.dart')
138 missing_msg = "Missing main.dart in project: %s" % sky_server_root 138 missing_msg = "Missing lib/main.dart in project: %s" % project_dir
139 else: 139 else:
140 # FIXME: This assumes the path is at the root of the project! 140 # FIXME: This assumes the path is at the root of the project!
141 # Instead we should walk up looking for a pubspec.yaml 141 # Instead we should walk up looking for a pubspec.yaml
142 sky_server_root = os.path.dirname(project_or_path) 142 sky_server_root = os.path.dirname(project_or_path)
143 main_dart = project_or_path 143 main_dart = project_or_path
144 missing_msg = "%s does not exist." % main_dart 144 missing_msg = "%s does not exist." % main_dart
145 145
146 if not os.path.isfile(main_dart): 146 if not os.path.isfile(main_dart):
147 print missing_msg 147 print missing_msg
148 return 2 148 return 2
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 args = parser.parse_args() 308 args = parser.parse_args()
309 pids = Pids.read_from(PID_FILE_PATH, PID_FILE_KEYS) 309 pids = Pids.read_from(PID_FILE_PATH, PID_FILE_KEYS)
310 exit_code = args.func(args, pids) 310 exit_code = args.func(args, pids)
311 # We could do this with an at-exit handler instead? 311 # We could do this with an at-exit handler instead?
312 pids.write_to(PID_FILE_PATH) 312 pids.write_to(PID_FILE_PATH)
313 sys.exit(exit_code) 313 sys.exit(exit_code)
314 314
315 315
316 if __name__ == '__main__': 316 if __name__ == '__main__':
317 SkyShellRunner().main() 317 SkyShellRunner().main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698