| 1 |
|
| 2 |
|
| 3 |
import codecs, httplib, json, os, urllib, shutil, subprocess, sys, argparse |
| 4 |
|
| 5 |
upstream_git = 'https://github.com/catapult-project/catapult.git' |
| 6 |
|
| 7 |
script_dir = os.path.dirname(os.path.abspath(sys.argv[0])) |
| 8 |
catapult_src_dir = os.path.join(script_dir, 'catapult-upstream') |
| 9 |
|
| 10 |
parser = argparse.ArgumentParser() |
| 11 |
parser.add_argument('trace_file_or_dir', |
| 12 |
help='Path to trace file or directory of trace files.') |
| 13 |
parser.add_argument('--output_file', dest='outfile', default=os.path.join(os.getcwd(), 'mapper_output.json'), |
| 14 |
help='Path to output file to store results.') |
| 15 |
parser.add_argument('--mapper_func', dest='func', default='AvgDrawFrame', |
| 16 |
help='Name of javascript mapper function in systrace_parser.html.') |
| 17 |
args = parser.parse_args() |
| 18 |
|
| 19 |
|
| 20 |
if not os.path.exists(catapult_src_dir): |
| 21 |
|
| 22 |
git_args = ['git', 'clone', upstream_git, catapult_src_dir] |
| 23 |
p = subprocess.Popen(git_args, stdout=subprocess.PIPE, cwd=script_dir) |
| 24 |
p.communicate() |
| 25 |
if p.wait() != 0: |
| 26 |
print 'Failed to checkout source from upstream git.' |
| 27 |
sys.exit(1) |
| 28 |
|
| 29 |
mapper_func_file = os.path.join(script_dir, 'systrace_parser.html') |
| 30 |
path_to_process_traces = os.path.join(catapult_src_dir, 'trace_processor/bin/process_traces') |
| 31 |
run_command = path_to_process_traces + " --mapper_handle " + mapper_func_file + ":" + args.func + " --output_file " + args.outfile + " " + args.trace_file_or_dir |
| 32 |
print run_command |
| 33 |
sys.exit(os.system(run_command)) |
| 34 |
|