diff options
author | Björn B. Brandenburg <bbb@cs.unc.edu> | 2010-05-25 15:26:08 -0400 |
---|---|---|
committer | Björn B. Brandenburg <bbb@cs.unc.edu> | 2010-05-25 15:26:08 -0400 |
commit | 473e87dba9e01cd4439d179603da7dec4aa32a63 (patch) | |
tree | 8ec91eaff6914d7197a86440140ec6191e6936ee | |
parent | cff6fda4e6acfd3978702618160a055981f09f97 (diff) |
Support optionally saving the produced script.
Useful for last-minute hand-tweaks.
-rwxr-xr-x | plot.py | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -14,6 +14,7 @@ options = [ | |||
14 | o(None, '--column', action='store_true', dest='column'), | 14 | o(None, '--column', action='store_true', dest='column'), |
15 | o(None, '--split', action='store_true', dest='split'), | 15 | o(None, '--split', action='store_true', dest='split'), |
16 | o(None, '--alternate', action='store_true', dest='alternate'), | 16 | o(None, '--alternate', action='store_true', dest='alternate'), |
17 | o(None, '--save-script', action='store_true', dest='save_script'), | ||
17 | ] | 18 | ] |
18 | 19 | ||
19 | defaults = { | 20 | defaults = { |
@@ -30,6 +31,7 @@ defaults = { | |||
30 | 'wide' : False, | 31 | 'wide' : False, |
31 | 'alternate' : False, | 32 | 'alternate' : False, |
32 | 'column' : False, | 33 | 'column' : False, |
34 | 'save_script' : False, | ||
33 | } | 35 | } |
34 | 36 | ||
35 | def decode(name): | 37 | def decode(name): |
@@ -42,12 +44,15 @@ def decode(name): | |||
42 | params[k] = v | 44 | params[k] = v |
43 | return params | 45 | return params |
44 | 46 | ||
45 | def get_data_tmpfile(datafile): | 47 | def get_data_tmpfile(datafile, target=None): |
46 | """Removes all comments form datafile, stores result in a temp file. | 48 | """Removes all comments form datafile, stores result in a temp file. |
47 | The temp file is returned.""" | 49 | The temp file is returned.""" |
48 | count = 0 | 50 | count = 0 |
49 | f = open(datafile, 'r') | 51 | f = open(datafile, 'r') |
50 | d = Tmp() | 52 | if target: |
53 | d = open(target, 'w') | ||
54 | else: | ||
55 | d = Tmp() | ||
51 | for line in f: | 56 | for line in f: |
52 | if len(line) > 1 and line[0] != '#': | 57 | if len(line) > 1 and line[0] != '#': |
53 | d.write(line) | 58 | d.write(line) |
@@ -288,8 +293,10 @@ class SchedPlotter(defapp.App): | |||
288 | if not self.options.paper: | 293 | if not self.options.paper: |
289 | p.title = 'Interrupt accounting under G-EDF: utilization ' + p.title | 294 | p.title = 'Interrupt accounting under G-EDF: utilization ' + p.title |
290 | 295 | ||
291 | # print str(p.gnuplot_commands()) | 296 | if self.options.save_script: |
292 | p.gnuplot_exec() | 297 | p.gnuplot_save(p.output + '.plot') |
298 | else: | ||
299 | p.gnuplot_exec() | ||
293 | 300 | ||
294 | def plot_rtss09(self, tmpfile, name, conf): | 301 | def plot_rtss09(self, tmpfile, name, conf): |
295 | title = scenario_heading(conf, want_period=True) | 302 | title = scenario_heading(conf, want_period=True) |
@@ -402,7 +409,10 @@ class SchedPlotter(defapp.App): | |||
402 | % bname) | 409 | % bname) |
403 | conf = decode(name) | 410 | conf = decode(name) |
404 | try: | 411 | try: |
405 | tmpfile = get_data_tmpfile(datafile) | 412 | if self.options.save_script: |
413 | tmpfile = get_data_tmpfile(datafile, target = "%s.data" % name ) | ||
414 | else: | ||
415 | tmpfile = get_data_tmpfile(datafile) | ||
406 | except IOError: | 416 | except IOError: |
407 | tmpfile = None | 417 | tmpfile = None |
408 | if tmpfile: | 418 | if tmpfile: |