Dennis Kempin | 1a8a5be | 2013-06-18 11:00:02 -0700 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | # Copyright (c) 2013 The Chromium OS 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 | |
Harry Cutts | 87cc600 | 2020-02-04 15:50:20 -0800 | [diff] [blame] | 6 | from __future__ import absolute_import |
| 7 | from __future__ import division |
Harry Cutts | 0edf157 | 2020-01-21 15:42:10 -0800 | [diff] [blame] | 8 | from __future__ import print_function |
| 9 | |
Dennis Kempin | 1a8a5be | 2013-06-18 11:00:02 -0700 | [diff] [blame] | 10 | from mtreplay import MTReplay |
Dennis Kempin | d0b722a | 2014-04-15 11:54:48 -0700 | [diff] [blame] | 11 | from mtlib import Log, PlatformDatabase |
Dennis Kempin | 1a8a5be | 2013-06-18 11:00:02 -0700 | [diff] [blame] | 12 | from optparse import OptionParser |
| 13 | import sys |
| 14 | |
| 15 | |
| 16 | usage = """Multitouch Replay Usage Examples: |
| 17 | |
| 18 | Replaying logs and print activity_log: |
| 19 | $ %prog filename.log (from file) |
| 20 | $ %prog 172.22.75.0 (from device ip address) |
| 21 | $ %prog http://feedback.google.com/... (from feedback report url) |
| 22 | |
| 23 | Print which platform this log is replayed on: |
| 24 | $ %prog log -p |
| 25 | |
| 26 | View gestures log |
| 27 | $ %prog log -v gestures-log |
| 28 | $ %prog log -vgl |
| 29 | |
| 30 | View evdev log |
| 31 | $ %prog log -v evdev-log |
| 32 | $ %prog log -vel |
| 33 | |
| 34 | View activity in MTEdit: |
| 35 | $ %prog log -v activity |
| 36 | $ %prog log -va""" |
| 37 | |
| 38 | |
| 39 | def main(argv): |
| 40 | parser = OptionParser(usage=usage) |
| 41 | parser.add_option('-p', '--platform', |
| 42 | dest='platform', action='store_true', default=False, |
| 43 | help='print platform this log is replayed on') |
| 44 | parser.add_option('-v', '--view', |
| 45 | dest='view', default=None, |
| 46 | help='select output of relay to view') |
Dennis Kempin | 41b3ddd | 2013-07-01 15:08:32 -0700 | [diff] [blame] | 47 | parser.add_option('--gdb', |
| 48 | dest='gdb', action='store_true', default=False, |
| 49 | help='setup gdb session to run replay') |
Dennis Kempin | d1e56a2 | 2013-07-17 14:11:46 -0700 | [diff] [blame] | 50 | parser.add_option('--force', '-f', |
| 51 | dest='force', default=None, |
| 52 | help='force platform for replay') |
Dennis Kempin | d0b722a | 2014-04-15 11:54:48 -0700 | [diff] [blame] | 53 | parser.add_option('--add-platform', '-a', |
| 54 | dest='add', default=None, |
| 55 | help='add platform of device to database') |
Dennis Kempin | 1a8a5be | 2013-06-18 11:00:02 -0700 | [diff] [blame] | 56 | (options, args) = parser.parse_args() |
| 57 | |
Dennis Kempin | d0b722a | 2014-04-15 11:54:48 -0700 | [diff] [blame] | 58 | if options.add: |
| 59 | PlatformDatabase.RegisterPlatformFromDevice(options.add) |
| 60 | return |
| 61 | |
Dennis Kempin | 1a8a5be | 2013-06-18 11:00:02 -0700 | [diff] [blame] | 62 | replay = MTReplay() |
Dennis Kempin | 41b3ddd | 2013-07-01 15:08:32 -0700 | [diff] [blame] | 63 | replay.Recompile() |
Dennis Kempin | 1a8a5be | 2013-06-18 11:00:02 -0700 | [diff] [blame] | 64 | |
| 65 | if len(args) != 1: |
| 66 | parser.print_help() |
| 67 | exit(-1) |
| 68 | |
| 69 | log = Log(args[0]) |
| 70 | |
| 71 | if options.platform: |
Dennis Kempin | 55af9cc | 2013-06-20 15:07:21 -0700 | [diff] [blame] | 72 | platform = replay.PlatformOf(log, True) |
| 73 | if platform: |
Harry Cutts | 0edf157 | 2020-01-21 15:42:10 -0800 | [diff] [blame] | 74 | print(platform.name) |
Dennis Kempin | 1a8a5be | 2013-06-18 11:00:02 -0700 | [diff] [blame] | 75 | return |
| 76 | |
Dennis Kempin | d1e56a2 | 2013-07-17 14:11:46 -0700 | [diff] [blame] | 77 | results = replay.Replay(log, force_platform=options.force, gdb=options.gdb) |
Dennis Kempin | 55af9cc | 2013-06-20 15:07:21 -0700 | [diff] [blame] | 78 | if results: |
| 79 | results.View(options.view) |
Dennis Kempin | 1a8a5be | 2013-06-18 11:00:02 -0700 | [diff] [blame] | 80 | |
| 81 | |
| 82 | if __name__ == '__main__': |
| 83 | main(sys.argv) |