diff options
author | Mac Mollison <mollison@cs.unc.edu> | 2010-04-11 01:02:17 -0400 |
---|---|---|
committer | Mac Mollison <mollison@cs.unc.edu> | 2010-04-11 01:02:17 -0400 |
commit | de297ade4c09eb63b30d567598bf33c0e1c38fc9 (patch) | |
tree | 07143c5b62fb67e63e802cddcfb00c7f55a4373c | |
parent | 4aacc808676506ea094772082c2aba8beaf49dfe (diff) |
Only import modules as needed
In the case of viz, the results in errors about not having
pycairo and pygtk potentially being printed only if the user actually
uses the -v flag
-rwxr-xr-x | unit-trace | 29 |
1 files changed, 14 insertions, 15 deletions
@@ -9,21 +9,6 @@ | |||
9 | # Setup | 9 | # Setup |
10 | ################################################################################ | 10 | ################################################################################ |
11 | 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 gedf_inversion_stat_printer | ||
19 | from unit_trace import stdout_printer | ||
20 | from unit_trace import progress | ||
21 | from unit_trace import skipper | ||
22 | from unit_trace import maxer | ||
23 | from unit_trace import earliest | ||
24 | from unit_trace import latest | ||
25 | from unit_trace import viz | ||
26 | |||
27 | # Get trace files from command line arguments | 12 | # Get trace files from command line arguments |
28 | from optparse import OptionParser | 13 | from optparse import OptionParser |
29 | usage = "usage: %prog [options] <one or more trace files>" | 14 | usage = "usage: %prog [options] <one or more trace files>" |
@@ -58,36 +43,47 @@ if len(traces) < 1: | |||
58 | # Pipeline | 43 | # Pipeline |
59 | ################################################################################ | 44 | ################################################################################ |
60 | 45 | ||
46 | # Import the unit_trace module | ||
47 | import unit_trace | ||
48 | |||
61 | # Read events from traces | 49 | # Read events from traces |
50 | from unit_trace import trace_reader | ||
62 | stream = trace_reader.trace_reader(traces) | 51 | stream = trace_reader.trace_reader(traces) |
63 | 52 | ||
64 | # Skip over records | 53 | # Skip over records |
65 | if options.skipnum > 0: | 54 | if options.skipnum > 0: |
55 | from unit_trace import skipper | ||
66 | stream = skipper.skipper(stream, options.skipnum) | 56 | stream = skipper.skipper(stream, options.skipnum) |
67 | 57 | ||
68 | # Enforce max number of records to parse | 58 | # Enforce max number of records to parse |
69 | if options.maxnum > 0: | 59 | if options.maxnum > 0: |
60 | from unit_trace import maxer | ||
70 | stream = maxer.maxer(stream, options.maxnum) | 61 | stream = maxer.maxer(stream, options.maxnum) |
71 | 62 | ||
72 | # Enfore earliest timestamp | 63 | # Enfore earliest timestamp |
73 | if options.earliest > 0: | 64 | if options.earliest > 0: |
65 | from unit_trace import earliest | ||
74 | stream = earliest.earliest(stream,options.earliest) | 66 | stream = earliest.earliest(stream,options.earliest) |
75 | 67 | ||
76 | # Enfore latest timestamp | 68 | # Enfore latest timestamp |
77 | if options.latest > 0: | 69 | if options.latest > 0: |
70 | from unit_trace import latest | ||
78 | stream = latest.latest(stream,options.latest) | 71 | stream = latest.latest(stream,options.latest) |
79 | 72 | ||
80 | # Filter out garbage events | 73 | # Filter out garbage events |
81 | if options.clean is True: | 74 | if options.clean is True: |
75 | from unit_trace import sanitizer | ||
82 | stream = sanitizer.sanitizer(stream) | 76 | stream = sanitizer.sanitizer(stream) |
83 | 77 | ||
84 | # Display progress information using stderr | 78 | # Display progress information using stderr |
85 | # e.g. # records completed so far, total time, etc. | 79 | # e.g. # records completed so far, total time, etc. |
86 | if options.progress is True: | 80 | if options.progress is True: |
81 | from unit_trace import progress | ||
87 | stream = progress.progress(stream) | 82 | stream = progress.progress(stream) |
88 | 83 | ||
89 | # Produce G-EDF error records | 84 | # Produce G-EDF error records |
90 | if options.gedf is True: | 85 | if options.gedf is True: |
86 | from unit_trace import gedf_test | ||
91 | stream = gedf_test.gedf_test(stream) | 87 | stream = gedf_test.gedf_test(stream) |
92 | 88 | ||
93 | # Filter some records out | 89 | # Filter some records out |
@@ -106,6 +102,7 @@ stream1, stream2, stream3 = itertools.tee(stream,3) | |||
106 | 102 | ||
107 | # Call standard out printer | 103 | # Call standard out printer |
108 | if options.stdout is True: | 104 | if options.stdout is True: |
105 | from unit_trace import stdout_printer | ||
109 | stdout_printer.stdout_printer(stream1) | 106 | stdout_printer.stdout_printer(stream1) |
110 | 107 | ||
111 | # Print G_EDF inversion statistics | 108 | # Print G_EDF inversion statistics |
@@ -115,8 +112,10 @@ if options.num_inversions > -1: | |||
115 | sys.stderr.write("You must enable the G-EDF test module to print" + | 112 | sys.stderr.write("You must enable the G-EDF test module to print" + |
116 | " G-EDF inversion statistics\n") | 113 | " G-EDF inversion statistics\n") |
117 | else: | 114 | else: |
115 | from unit_trace import gedf_inversion_stat_printer | ||
118 | gedf_inversion_stat_printer.gedf_inversion_stat_printer(stream2,options.num_inversions) | 116 | gedf_inversion_stat_printer.gedf_inversion_stat_printer(stream2,options.num_inversions) |
119 | 117 | ||
120 | # Call visualizer | 118 | # Call visualizer |
121 | if options.visualize is True: | 119 | if options.visualize is True: |
120 | from unit_trace import viz | ||
122 | viz.visualizer.visualizer(stream3) | 121 | viz.visualizer.visualizer(stream3) |