OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 # Copyright (c) 2012 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 """Reads a trace. Mostly for testing.""" | |
7 | |
8 import logging | |
9 import optparse | |
10 import os | |
11 import sys | |
12 | |
13 import trace_inputs | |
14 | |
15 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | |
16 ROOT_DIR = os.path.dirname(os.path.dirname(BASE_DIR)) | |
17 | |
18 | |
19 def read_trace(logname, root_dir, cwd_dir, product_dir): | |
20 # Resolve any symlink | |
21 root_dir = os.path.realpath(root_dir) | |
22 api = trace_inputs.get_api() | |
23 _, _, _, _, simplified = trace_inputs.load_trace(logname, root_dir, api) | |
24 variables = trace_inputs.generate_dict(simplified, cwd_dir, product_dir) | |
25 trace_inputs.pretty_print(variables, sys.stdout) | |
26 | |
27 | |
28 def main(): | |
29 """CLI frontend to validate arguments.""" | |
30 parser = optparse.OptionParser( | |
31 usage='%prog <options> [gtest]') | |
32 parser.add_option( | |
33 '-v', '--verbose', action='count', default=0, help='Use multiple times') | |
Roger Tawa OOO till Jul 10th
2012/05/11 14:17:07
i guess you can use it 0, 1, or 2 times. anything
| |
34 parser.add_option( | |
35 '-c', '--cwd', | |
36 default='chrome', | |
37 help='Signal to start the process from this relative directory. When ' | |
38 'specified, outputs the inputs files in a way compatible for ' | |
39 'gyp processing. Should be set to the relative path containing the ' | |
40 'gyp file, e.g. \'chrome\' or \'net\'') | |
41 parser.add_option( | |
42 '-p', '--product-dir', | |
43 default='out/Release', | |
44 help='Directory for PRODUCT_DIR. Default: %default') | |
45 parser.add_option( | |
46 '--root-dir', | |
47 default=ROOT_DIR, | |
48 help='Root directory to base everything off. Default: %default') | |
49 options, args = parser.parse_args() | |
50 | |
51 level = [logging.ERROR, logging.INFO, logging.DEBUG][min(2, options.verbose)] | |
52 logging.basicConfig( | |
53 level=level, | |
54 format='%(levelname)5s %(module)15s(%(lineno)3d):%(message)s') | |
55 | |
56 if len(args) != 1: | |
57 parser.error('Please provide the log to read') | |
58 if not options.product_dir: | |
59 parser.error('--product-dir is required') | |
60 if not options.cwd: | |
61 parser.error('--cwd is required') | |
62 | |
63 return read_trace( | |
64 args[0], | |
65 options.root_dir, | |
66 options.cwd, | |
67 options.product_dir) | |
68 | |
69 | |
70 if __name__ == '__main__': | |
71 sys.exit(main()) | |
OLD | NEW |