From 473e87dba9e01cd4439d179603da7dec4aa32a63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20B=2E=20Brandenburg?= Date: Tue, 25 May 2010 15:26:08 -0400 Subject: Support optionally saving the produced script. Useful for last-minute hand-tweaks. --- plot.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/plot.py b/plot.py index f9039c9..b961c6d 100755 --- a/plot.py +++ b/plot.py @@ -14,6 +14,7 @@ options = [ o(None, '--column', action='store_true', dest='column'), o(None, '--split', action='store_true', dest='split'), o(None, '--alternate', action='store_true', dest='alternate'), + o(None, '--save-script', action='store_true', dest='save_script'), ] defaults = { @@ -30,6 +31,7 @@ defaults = { 'wide' : False, 'alternate' : False, 'column' : False, + 'save_script' : False, } def decode(name): @@ -42,12 +44,15 @@ def decode(name): params[k] = v return params -def get_data_tmpfile(datafile): +def get_data_tmpfile(datafile, target=None): """Removes all comments form datafile, stores result in a temp file. The temp file is returned.""" count = 0 f = open(datafile, 'r') - d = Tmp() + if target: + d = open(target, 'w') + else: + d = Tmp() for line in f: if len(line) > 1 and line[0] != '#': d.write(line) @@ -288,8 +293,10 @@ class SchedPlotter(defapp.App): if not self.options.paper: p.title = 'Interrupt accounting under G-EDF: utilization ' + p.title -# print str(p.gnuplot_commands()) - p.gnuplot_exec() + if self.options.save_script: + p.gnuplot_save(p.output + '.plot') + else: + p.gnuplot_exec() def plot_rtss09(self, tmpfile, name, conf): title = scenario_heading(conf, want_period=True) @@ -402,7 +409,10 @@ class SchedPlotter(defapp.App): % bname) conf = decode(name) try: - tmpfile = get_data_tmpfile(datafile) + if self.options.save_script: + tmpfile = get_data_tmpfile(datafile, target = "%s.data" % name ) + else: + tmpfile = get_data_tmpfile(datafile) except IOError: tmpfile = None if tmpfile: -- cgit v1.2.2