diff options
| author | Mac Mollison <mollison@cs.unc.edu> | 2010-03-14 04:30:31 -0400 |
|---|---|---|
| committer | Mac Mollison <mollison@cs.unc.edu> | 2010-03-14 04:30:31 -0400 |
| commit | ecc35d07ec93109310ad23b64b6842505f8a210b (patch) | |
| tree | fe5a9364f7c4cd0b5a692d7d1f4c5dd7fc7dfc5d /unit-trace | |
| parent | c8210c3cef340e8280658e847cc70958be77eb26 (diff) | |
Installation improvements
unit-trace.py -> unit-trace and placed in
/usr/bin
Diffstat (limited to 'unit-trace')
| -rwxr-xr-x | unit-trace | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/unit-trace b/unit-trace new file mode 100755 index 0000000..93ab169 --- /dev/null +++ b/unit-trace | |||
| @@ -0,0 +1,114 @@ | |||
| 1 | #!/usr/bin/python | ||
| 2 | |||
| 3 | ################################################################################ | ||
| 4 | # Description | ||
| 5 | ################################################################################ | ||
| 6 | # Control script for unit-trace | ||
| 7 | |||
| 8 | ################################################################################ | ||
| 9 | # Setup | ||
| 10 | ################################################################################ | ||
| 11 | |||
| 12 | # Import the modules we need. You should not need to know about | ||
| 13 | # their internals. | ||
| 14 | import unit_trace | ||
| 15 | from unit_trace import trace_reader | ||
| 16 | from unit_trace import sanitizer | ||
| 17 | from unit_trace import gedf_test | ||
| 18 | from unit_trace import stats | ||
| 19 | from unit_trace import stdout_printer | ||
| 20 | from unit_trace import visualizer | ||
| 21 | from unit_trace import progress | ||
| 22 | from unit_trace import skipper | ||
| 23 | from unit_trace import maxer | ||
| 24 | from unit_trace import earliest | ||
| 25 | from unit_trace import latest | ||
| 26 | |||
| 27 | # Get trace files from command line arguments | ||
| 28 | from optparse import OptionParser | ||
| 29 | usage = "usage: %prog [options] <one or more trace files>" | ||
| 30 | parser = OptionParser(usage=usage) | ||
| 31 | parser.add_option("-s", "--skip", dest="skipnum", default=0, type=int, | ||
| 32 | help="Skip over a fixed number of records") | ||
| 33 | parser.add_option("-m", "--max", dest="maxnum", default=0, type=int, | ||
| 34 | help="Maximum number of records to parse") | ||
| 35 | parser.add_option("-p", "--progress", action="store_true", dest="progress", | ||
| 36 | default=False, help="Show parsing progress") | ||
| 37 | parser.add_option("-g", "--gedf", action="store_true", dest="gedf", | ||
| 38 | default=False, help="Run G-EDF test") | ||
| 39 | parser.add_option("-i", "--info", action="store_true", dest="info", | ||
| 40 | default=False, help="Show statistical info") | ||
| 41 | parser.add_option("-o", "--stdout", action="store_true", dest="stdout", | ||
| 42 | default=False, help="Use stdout_printer") | ||
| 43 | parser.add_option("-v", "--visual", action="store_true", dest="visualize", | ||
| 44 | default=False, help="Use visualizer") | ||
| 45 | parser.add_option("-c", "--clean", action="store_true", dest="clean", | ||
| 46 | default=False, help="Use sanitizer to clean garbage records") | ||
| 47 | parser.add_option("-e", "--earliest", default=0, type=int, dest="earliest", | ||
| 48 | help="Earliest timestamp of interst") | ||
| 49 | parser.add_option("-l", "--latest", default=0, type=int, dest="latest", | ||
| 50 | help="Latest timestamp of interst") | ||
| 51 | (options, traces) = parser.parse_args() | ||
| 52 | traces = list(traces) | ||
| 53 | if len(traces) < 1: | ||
| 54 | parser.print_help() | ||
| 55 | exit() | ||
| 56 | |||
| 57 | ################################################################################ | ||
| 58 | # Pipeline | ||
| 59 | ################################################################################ | ||
| 60 | |||
| 61 | # Read events from traces | ||
| 62 | stream = trace_reader.trace_reader(traces) | ||
| 63 | |||
| 64 | # Skip over records | ||
| 65 | if options.skipnum > 0: | ||
| 66 | stream = skipper.skipper(stream, options.skipnum) | ||
| 67 | |||
| 68 | # Enforce max number of records to parse | ||
| 69 | if options.maxnum > 0: | ||
| 70 | stream = maxer.maxer(stream, options.maxnum) | ||
| 71 | |||
| 72 | # Enfore earliest timestamp | ||
| 73 | if options.earliest > 0: | ||
| 74 | stream = earliest.earliest(stream,options.earliest) | ||
| 75 | |||
| 76 | # Enfore latest timestamp | ||
| 77 | if options.latest > 0: | ||
| 78 | stream = latest.latest(stream,options.latest) | ||
| 79 | |||
| 80 | # Filter out garbage events | ||
| 81 | if options.clean is True: | ||
| 82 | stream = sanitizer.sanitizer(stream) | ||
| 83 | |||
| 84 | # Display progress information using stderr | ||
| 85 | # e.g. # records completed so far, total time, etc. | ||
| 86 | if options.progress is True: | ||
| 87 | stream = progress.progress(stream) | ||
| 88 | |||
| 89 | # Produce G-EDF error records | ||
| 90 | if options.gedf is True: | ||
| 91 | stream = gedf_test.gedf_test(stream) | ||
| 92 | |||
| 93 | # Produce a statistics record | ||
| 94 | if options.info is True: | ||
| 95 | stream = stats.stats(stream) | ||
| 96 | |||
| 97 | # Filter some records out | ||
| 98 | #def my_filter(record): | ||
| 99 | # if record.record_type == 'error' and record.type_name == 'inversion_end': | ||
| 100 | # if record.job.inversion_end - record.job.inversion_start < 4000000: | ||
| 101 | # return False | ||
| 102 | # return True | ||
| 103 | #stream = filter(my_filter, stream) | ||
| 104 | |||
| 105 | # Output | ||
| 106 | if options.stdout is True and options.visualize is True: | ||
| 107 | import itertools | ||
| 108 | stream1, stream2 = itertools.tee(stream,2) | ||
| 109 | stdout_printer.stdout_printer(stream1) | ||
| 110 | visualizer.visualizer(stream2) | ||
| 111 | elif options.stdout is True: | ||
| 112 | stdout_printer.stdout_printer(stream) | ||
| 113 | elif options.visualize is True: | ||
| 114 | visualizer.visualizer(stream) | ||
