Added plotting graph to file.
authorStanislaw Klekot <dozzie@jarowit.net>
Sun, 27 Oct 2013 08:00:32 +0000 (09:00 +0100)
committerStanislaw Klekot <dozzie@jarowit.net>
Sun, 27 Oct 2013 08:00:32 +0000 (09:00 +0100)
rrdplot

diff --git a/rrdplot b/rrdplot
index ee1c483..2100845 100755 (executable)
--- a/rrdplot
+++ b/rrdplot
@@ -86,7 +86,7 @@ class DisplayWindow:
     # }}}
     #-------------------------------------------------------
 
-    self.reload_image()
+    #self.reload_image() # NOTE: it's not quite necessary
     self.window.show()
 
   def reload_image(self):
@@ -257,6 +257,9 @@ if opts.time_start and not opts.time_end:
 if opts.time_start and opts.time_recent:
   o.error("Can't have both start time and recent")
 
+if opts.operation == 'png' and not opts.output_file:
+  o.error("Output PNG file not specified")
+
 rrd_file = args[0]
 
 # }}}
@@ -301,7 +304,12 @@ if opts.operation == 'rrdgraph':
   for c in cmds:
     print c
 elif opts.operation == 'png':
-  pass # TODO: use opts.output
+  if opts.width == None:
+    opts.width = 500
+  if opts.height == None:
+    opts.height = 310
+  plotter.resize(opts.width, opts.height)
+  open(opts.output_file, 'w').write(plotter.plot())
 else:
   display_window = DisplayWindow(plotter, opts.refresh)
   display_window.main()