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

Side by Side Diff: sky/tools/shelldb

Issue 1156993004: Sky shelldb should restart app when using --no_install and forward observatory port (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 7 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 from skypy.skyserver import SkyServer 6 from skypy.skyserver import SkyServer
7 import argparse 7 import argparse
8 import json 8 import json
9 import logging 9 import logging
10 import os 10 import os
11 import re 11 import re
12 import signal 12 import signal
13 import subprocess 13 import subprocess
14 import sys 14 import sys
15 import time 15 import time
16 import urlparse 16 import urlparse
17 17
18 SKY_TOOLS_DIR = os.path.dirname(os.path.abspath(__file__)) 18 SKY_TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
19 SKY_ROOT = os.path.dirname(SKY_TOOLS_DIR) 19 SKY_ROOT = os.path.dirname(SKY_TOOLS_DIR)
20 SRC_ROOT = os.path.dirname(SKY_ROOT) 20 SRC_ROOT = os.path.dirname(SKY_ROOT)
21 21
22 SKY_SERVER_PORT = 9888 22 SKY_SERVER_PORT = 9888
23 OBSERVATORY_PORT = 8181
23 DEFAULT_URL = "sky://domokit.github.io/sky_home" 24 DEFAULT_URL = "sky://domokit.github.io/sky_home"
24 APK_NAME = 'SkyDemo.apk' 25 APK_NAME = 'SkyDemo.apk'
25 ADB_PATH = os.path.join(SRC_ROOT, 26 ADB_PATH = os.path.join(SRC_ROOT,
26 'third_party/android_tools/sdk/platform-tools/adb') 27 'third_party/android_tools/sdk/platform-tools/adb')
27 ANDROID_PACKAGE = "org.domokit.sky.demo" 28 ANDROID_PACKAGE = "org.domokit.sky.demo"
28 29
29 PID_FILE_PATH = "/tmp/skydemo.pids" 30 PID_FILE_PATH = "/tmp/skydemo.pids"
30 PID_FILE_KEYS = frozenset([ 31 PID_FILE_KEYS = frozenset([
31 'remote_sky_server_port', 32 'remote_sky_server_port',
32 'sky_server_pid', 33 'sky_server_pid',
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 sky_server = self._sky_server_for_args(args, packages_root) 188 sky_server = self._sky_server_for_args(args, packages_root)
188 pids['sky_server_pid'] = sky_server.start() 189 pids['sky_server_pid'] = sky_server.start()
189 pids['sky_server_port'] = sky_server.port 190 pids['sky_server_port'] = sky_server.port
190 pids['sky_server_root'] = sky_server.root 191 pids['sky_server_root'] = sky_server.root
191 192
192 pids['build_dir'] = os.path.abspath(args.build_dir) 193 pids['build_dir'] = os.path.abspath(args.build_dir)
193 194
194 if args.install: 195 if args.install:
195 # -r to replace an existing apk, -d to allow version downgrade. 196 # -r to replace an existing apk, -d to allow version downgrade.
196 subprocess.check_call([ADB_PATH, 'install', '-r', '-d', apk_path]) 197 subprocess.check_call([ADB_PATH, 'install', '-r', '-d', apk_path])
198 else:
199 subprocess.check_call([
200 ADB_PATH, 'shell', 'am', 'force-stop', ANDROID_PACKAGE
201 ])
202
203 # Set up port forwarding for observatory
204 port_string = 'tcp:%s' % OBSERVATORY_PORT
205 subprocess.check_call([
206 ADB_PATH, 'forward', port_string, port_string
207 ])
197 208
198 port_string = 'tcp:%s' % sky_server.port 209 port_string = 'tcp:%s' % sky_server.port
199 subprocess.check_call([ 210 subprocess.check_call([
200 ADB_PATH, 'reverse', port_string, port_string 211 ADB_PATH, 'reverse', port_string, port_string
201 ]) 212 ])
202 pids['remote_sky_server_port'] = sky_server.port 213 pids['remote_sky_server_port'] = sky_server.port
203 214
204 subprocess.check_call([ADB_PATH, 'shell', 215 subprocess.check_call([ADB_PATH, 'shell',
205 'am', 'start', 216 'am', 'start',
206 '-a', 'android.intent.action.VIEW', 217 '-a', 'android.intent.action.VIEW',
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 args = parser.parse_args() 359 args = parser.parse_args()
349 pids = Pids.read_from(PID_FILE_PATH, PID_FILE_KEYS) 360 pids = Pids.read_from(PID_FILE_PATH, PID_FILE_KEYS)
350 exit_code = args.func(args, pids) 361 exit_code = args.func(args, pids)
351 # We could do this with an at-exit handler instead? 362 # We could do this with an at-exit handler instead?
352 pids.write_to(PID_FILE_PATH) 363 pids.write_to(PID_FILE_PATH)
353 sys.exit(exit_code) 364 sys.exit(exit_code)
354 365
355 366
356 if __name__ == '__main__': 367 if __name__ == '__main__':
357 SkyShellRunner().main() 368 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