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

Side by Side Diff: mojo/devtools/common/debugger

Issue 1156823004: Add a cli for a running mojo:debugger. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Add a blank line. Created 5 years, 6 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
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 import argparse
7 import requests
8 import sys
9
10 _MOJO_DEBUGGER_PORT = 7777
11
12
13 def _send_request(request):
14 url = 'http://localhost:%s/%s' % (_MOJO_DEBUGGER_PORT, request)
15 return requests.get(url)
16
17
18 def start_tracing_command(args):
19 _send_request('start_tracing')
20 print "Started tracing."
21
22
23 def stop_tracing_command(args):
24 file_name = args.file_name
25 trace = _send_request('stop_tracing').content
26 with open(file_name, "wb") as trace_file:
27 trace_file.write('{"traceEvents":[')
28 trace_file.write(trace)
29 trace_file.write(']}')
30 print "Trace saved in %s" % file_name
31
32
33 def main():
34 parser = argparse.ArgumentParser(description='Command-line interface for '
35 'mojo:debugger')
36 subparsers = parser.add_subparsers(help='sub-command help')
37
38 start_tracing_parser = subparsers.add_parser('start_tracing',
39 help='starts tracing')
40 start_tracing_parser.set_defaults(func=start_tracing_command)
41
42 stop_tracing_parser = subparsers.add_parser('stop_tracing',
43 help='stops tracing')
44 stop_tracing_parser.add_argument('file_name', type=str, default='mojo.trace')
45 stop_tracing_parser.set_defaults(func=stop_tracing_command)
46
47 args = parser.parse_args()
48 args.func(args)
49 return 0
50
51 if __name__ == '__main__':
52 sys.exit(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