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

Side by Side Diff: sky/tools/skydb

Issue 849053006: Make skydb stop actually clear the pid file (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 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
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 def _create_paths_for_build_dir(self, build_dir): 136 def _create_paths_for_build_dir(self, build_dir):
137 # skypy.paths.Paths takes a root-relative build_dir argument. :( 137 # skypy.paths.Paths takes a root-relative build_dir argument. :(
138 abs_build_dir = os.path.abspath(build_dir) 138 abs_build_dir = os.path.abspath(build_dir)
139 root_relative_build_dir = os.path.relpath(abs_build_dir, SRC_ROOT) 139 root_relative_build_dir = os.path.relpath(abs_build_dir, SRC_ROOT)
140 return skypy.paths.Paths(root_relative_build_dir) 140 return skypy.paths.Paths(root_relative_build_dir)
141 141
142 def start_command(self, args): 142 def start_command(self, args):
143 # FIXME: Lame that we use self for a command-specific variable. 143 # FIXME: Lame that we use self for a command-specific variable.
144 self.paths = self._create_paths_for_build_dir(args.build_dir) 144 self.paths = self._create_paths_for_build_dir(args.build_dir)
145 self.stop_command(None) # Quit any existing process. 145 self.stop_command(None) # Quit any existing process.
146 self.pids = {} # Clear out our pid file.
147 146
148 if not os.path.exists(self.paths.mojo_shell_path): 147 if not os.path.exists(self.paths.mojo_shell_path):
149 print "mojo_shell not found in build_dir '%s'" % args.build_dir 148 print "mojo_shell not found in build_dir '%s'" % args.build_dir
150 print "Are you sure you sure that's a valid build_dir location?" 149 print "Are you sure you sure that's a valid build_dir location?"
151 print "See skydb start --help for more info" 150 print "See skydb start --help for more info"
152 sys.exit(2) 151 sys.exit(2)
153 152
154 # FIXME: This is probably not the right way to compute is_android 153 # FIXME: This is probably not the right way to compute is_android
155 # from the build directory? 154 # from the build directory?
156 gn_args = gn_args_from_build_dir(args.build_dir) 155 gn_args = gn_args_from_build_dir(args.build_dir)
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 # adb forward --remove takes the *host* port, not the remote port. 242 # adb forward --remove takes the *host* port, not the remote port.
244 port_string = 'tcp:%s' % self.pids['sky_command_port'] 243 port_string = 'tcp:%s' % self.pids['sky_command_port']
245 subprocess.call(['adb', 'forward', '--remove', port_string]) 244 subprocess.call(['adb', 'forward', '--remove', port_string])
246 245
247 subprocess.call([ 246 subprocess.call([
248 'adb', 'shell', 'am', 'force-stop', ANDROID_PACKAGE]) 247 'adb', 'shell', 'am', 'force-stop', ANDROID_PACKAGE])
249 248
250 if 'remote_gdbserver_port' in self.pids: 249 if 'remote_gdbserver_port' in self.pids:
251 port_string = 'tcp:%s' % self.pids['remote_gdbserver_port'] 250 port_string = 'tcp:%s' % self.pids['remote_gdbserver_port']
252 subprocess.call(['adb', 'forward', '--remove', port_string]) 251 subprocess.call(['adb', 'forward', '--remove', port_string])
252 self.pids = {} # Clear out our pid file.
253 253
254 def load_command(self, args): 254 def load_command(self, args):
255 if not urlparse.urlparse(args.url_or_path).scheme: 255 if not urlparse.urlparse(args.url_or_path).scheme:
256 # The load happens on the remote device, use the remote port. 256 # The load happens on the remote device, use the remote port.
257 remote_sky_server_port = self.pids.get('remote_sky_server_port', 257 remote_sky_server_port = self.pids.get('remote_sky_server_port',
258 self.pids['sky_server_port']) 258 self.pids['sky_server_port'])
259 url = SkyServer.url_for_path(remote_sky_server_port, 259 url = SkyServer.url_for_path(remote_sky_server_port,
260 self.pids['sky_server_root'], args.url_or_path) 260 self.pids['sky_server_root'], args.url_or_path)
261 else: 261 else:
262 url = args.url_or_path 262 url = args.url_or_path
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 load_parser.set_defaults(func=self.load_command) 394 load_parser.set_defaults(func=self.load_command)
395 395
396 args = parser.parse_args() 396 args = parser.parse_args()
397 args.func(args) 397 args.func(args)
398 398
399 self._write_pid_file(PID_FILE_PATH, self.pids) 399 self._write_pid_file(PID_FILE_PATH, self.pids)
400 400
401 401
402 if __name__ == '__main__': 402 if __name__ == '__main__':
403 SkyDebugger().main() 403 SkyDebugger().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