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

Side by Side Diff: sky/tools/skydb

Issue 682153003: Add a sky_server for running sky apps (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« sky/tools/sky_server ('K') | « sky/tools/sky_server ('k') | 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 import argparse 6 import argparse
7 import os 7 import os
8 import subprocess 8 import subprocess
9 import sys 9 import sys
10 import urlparse 10 import urlparse
11 11
12 12
13 BUILD_DIRECTORY = 'out' 13 BUILD_DIRECTORY = 'out'
14 CONFIG_DIRECTORY = 'Debug' 14 CONFIG_DIRECTORY = 'Debug'
15 MOJO_SHELL_PATH = os.path.abspath(os.path.join(__file__, os.pardir, os.pardir, 15 SKY_TOOLS_DIRECTORY = os.path.abspath(os.path.join(__file__, os.pardir))
16 MOJO_SHELL_PATH = os.path.abspath(os.path.join(SKY_TOOLS_DIRECTORY, os.pardir,
16 os.pardir, BUILD_DIRECTORY, CONFIG_DIRECTORY, 'mojo_shell')) 17 os.pardir, BUILD_DIRECTORY, CONFIG_DIRECTORY, 'mojo_shell'))
17 18
18 SUPPORTED_MIME_TYPES = [ 19 SUPPORTED_MIME_TYPES = [
19 'text/html', 20 'text/html',
20 'text/sky', 21 'text/sky',
21 'text/plain', 22 'text/plain',
22 ] 23 ]
23 24
24 def start_http_server_for_file(path): 25 def start_http_server_for_file(path):
25 HTTP_PORT = 9999 26 HTTP_PORT = 9999
26 directory = os.path.dirname(os.path.abspath(path))
27 server_command = [ 27 server_command = [
28 'python', 28 os.path.join(SKY_TOOLS_DIRECTORY, 'sky_server'),
29 '-m', 29 os.path.dirname(os.path.abspath(path)),
30 'SimpleHTTPServer', 30 str(HTTP_PORT),
31 str(HTTP_PORT)
32 ] 31 ]
33 subprocess.Popen(server_command, cwd=directory) 32 subprocess.Popen(server_command)
34 return 'http://localhost:%s/%s' % (HTTP_PORT, os.path.basename(path)) 33 return 'http://localhost:%s/%s' % (HTTP_PORT, os.path.basename(path))
35 34
36 35
37 def main(): 36 def main():
38 parser = argparse.ArgumentParser(description='Sky launcher/debugger') 37 parser = argparse.ArgumentParser(description='Sky launcher/debugger')
39 parser.add_argument('--gdb', action='store_true') 38 parser.add_argument('--gdb', action='store_true')
40 parser.add_argument('url', nargs='?', type=str) 39 parser.add_argument('url', nargs='?', type=str)
41 args = parser.parse_args() 40 args = parser.parse_args()
42 41
43 content_handlers = ['%s,%s' % (mime_type, 'mojo://sky_viewer/') 42 content_handlers = ['%s,%s' % (mime_type, 'mojo://sky_viewer/')
(...skipping 13 matching lines...) Expand all
57 prompt_args = '--args-for=mojo://sky_debugger_prompt/ %s' % url 56 prompt_args = '--args-for=mojo://sky_debugger_prompt/ %s' % url
58 shell_command.append(prompt_args) 57 shell_command.append(prompt_args)
59 if args.gdb: 58 if args.gdb:
60 shell_command = ['gdb', '--args'] + shell_command 59 shell_command = ['gdb', '--args'] + shell_command
61 60
62 print ' '.join(shell_command) 61 print ' '.join(shell_command)
63 subprocess.check_call(shell_command) 62 subprocess.check_call(shell_command)
64 63
65 64
66 if __name__ == '__main__': 65 if __name__ == '__main__':
67 main() 66 try:
67 main()
68 except (KeyboardInterrupt, SystemExit):
69 print "Quitting"
OLDNEW
« sky/tools/sky_server ('K') | « sky/tools/sky_server ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698