lundi 29 décembre 2014

apache script (run-plot-make page)

I am trying to write a python script to do this things:



  1. take variable from page

  2. pass variable to gnuplot and plot something

  3. output some html code with plotted data (.png output)


I have this for now:



#!"C:\Python27\python.exe"
# -*- coding: UTF-8 -*-

# enable debugging
# Import modules for CGI handling
import cgi, cgitb

import subprocess
import os

#data = "steps" (this will be passed from web)
#output = "steps" (this will be passed from web)

proc = subprocess.Popen(['gnuplot'],
shell=True,
stdin=subprocess.PIPE,
)
proc.stdin.write('set output "%s+.png" %output \n')
proc.stdin.write('I DO NOT KNOW') # I do not know how to write it
proc.stdin.write('quit\n')


What sould I write in line (i do not know) to plot data this way:



plot \
\
'steps.txt' u 0:3 sm cs w l ls 1 t 'X-suradnice',\
'steps.txt' u 0:4 sm cs w l ls 2 t 'Y-suradnice',\
'steps.txt' u 0:5 sm cs w l ls 3 t 'Z-suradnice'


And then in the same script print them as html output something like this.



print "Content-type:text/html\r\n\r\n"
print "<html>"
print "<head>"
print "<title>this is my output</title>"
print "</head>"
print "<body>"
#print "<img src="output.png" alt="img">"
print "</body>"
print "</html>"


Thank you guys, i am hopeless with this... I hope u understand what I want :/





Aucun commentaire:

Enregistrer un commentaire