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

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: 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, payload=None):
14 url = 'http://localhost:%s/%s' % (_MOJO_DEBUGGER_PORT, request)
15 if payload:
16 response = requests.post(url, payload)
17 else:
18 response = requests.get(url)
19 return response
qsr 2015/06/03 15:20:40 You probably should remove payload as you do not u
ppi 2015/06/03 15:24:04 Done.
20
21
22 def start_tracing_command(args):
23 _send_request('start_tracing')
24 print "Started tracing."
25
26
27 def stop_tracing_command(args):
28 file_name = args.file_name
29 trace = _send_request('stop_tracing').content
30 with open(file_name, "wb") as trace_file:
31 trace_file.write('{"traceEvents":[')
32 trace_file.write(trace)
33 trace_file.write(']}')
34 print "Trace saved in %s" % file_name
35
36
37 def main():
38 parser = argparse.ArgumentParser(description='Command-line interface for '
39 'mojo:debugger')
40 subparsers = parser.add_subparsers(help='sub-command help')
41
42 start_tracing_parser = subparsers.add_parser('start_tracing',
43 help='starts tracing')
44 start_tracing_parser.set_defaults(func=start_tracing_command)
45
46 stop_tracing_parser = subparsers.add_parser('stop_tracing',
47 help='stops tracing')
48 stop_tracing_parser.add_argument('file_name', type=str, default='mojo.trace')
49 stop_tracing_parser.set_defaults(func=stop_tracing_command)
50
51 args = parser.parse_args()
52 args.func(args)
53 return 0
54
55 if __name__ == '__main__':
56 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