Edgewall Software

ProcessorBazaar: graphviz.py

File graphviz.py, 0.5 kB (added by Vegard Eriksen, 3 years ago)

Graphviz-processor.

Line 
1# Set this to the directory you want the images stored in. Web server must have write access.
2images_folder = '/var/www/dev.jvnv.net/htdocs/trac/graphviz'
3# Base URL of the folder.
4images_url = '/trac/graphviz'
5
6import md5
7import os
8
9def execute(hdf, text, env):
10        md5sum = md5.new(text).hexdigest()
11        if not os.access('%s/%s.png' % (images_folder, md5sum), os.F_OK):
12                dot = os.popen('dot -Tpng -o%s/%s.png' % (images_folder, md5sum), 'w')
13                dot.write(text)
14                dot.close()
15        return '<img src="%s/%s.png" alt="Graph" />\n' % (images_url, md5sum)