#!@PYTHON@ # -*- python -*- # Copyright (C) 2003 Laboratoire d'Informatique de Paris 6 (LIP6), # département Systèmes Répartis Coopératifs (SRC), Université Pierre # et Marie Curie. # # This file is part of Spot, a model checking library. # # Spot is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Spot is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public # License for more details. # # You should have received a copy of the GNU General Public License # along with Spot; see the file COPYING. If not, write to the Free # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. import sys import os import cgi import cgitb; cgitb.enable() sys.path.insert(0, '@pythondir@') # Directory for temporary files (images and other auxiliary files). imgdir = 'spotimg' # Cleanup stale files from our image directory. os.system('find ' + imgdir + ' -type f -amin +10 -print | xargs rm -f') myself = os.environ['SCRIPT_NAME']; form = cgi.FieldStorage() filled = form.has_key('formula') # FIXME: This assumes Apache. uid = os.environ['UNIQUE_ID']; imgprefix = imgdir + '/' + uid def escaped_print_dot(dict, what): print '
'; sys.stdout.flush()
s = spot.ostringstream()
spot.bdd_print_dot(s, dict, what)
print cgi.escape(s.str())
del s
print ''; sys.stdout.flush()
def escaped_print_set(dict, what):
print ''; sys.stdout.flush()
s = spot.ostringstream()
spot.bdd_print_set(s, dict, what)
print cgi.escape(s.str())
del s
print ''; sys.stdout.flush()
print "Content-Type: text/html"
print
os.close(sys.stderr.fileno())
os.dup2(sys.stdout.fileno(), sys.stderr.fileno())
import spot
print "' sys.stdout.flush() sys.stderr.flush() pel = spot.empty_parse_error_list() f = spot.parse(formula, pel, env, show_parse) if show_parse: print '' print '
' err = spot.format_parse_errors(spot.get_cout(), formula, pel) print '' if not f: print '
Aborting...
' sys.exit(0) if err: print 'Continuing anyway...
' print "Formula is", f, "
'; sys.stdout.flush()
s = spot.ostringstream()
spot.dotty(s, f)
print cgi.escape(s.str())
del s
print ''; sys.stdout.flush()
if show_formula_gif:
outfile = spot.ofstream(imgprefix + '-f.dot')
spot.dotty(outfile, f)
del outfile
os.spawnlp(os.P_WAIT, 'dot', 'dot', '-Tgif', '-Gsize=14,14', '-o',
imgprefix + '-f.gif', imgprefix + '-f.dot')
os.spawnlp(os.P_WAIT, 'convert', 'convert',
imgprefix + '-f.gif', imgprefix + '-f.png')
print '
'
print 'Building automaton...', sys.stdout.flush() if trans_lacim: automaton = spot.ltl_to_tgba_lacim(f, dict) elif trans_fm: automaton = spot.ltl_to_tgba_fm(f, dict) print 'done.
' sys.stdout.flush() if show_automaton_dot: print ''; sys.stdout.flush()
s = spot.ostringstream()
spot.dotty_reachable(s, automaton)
print cgi.escape(s.str())
del s
print ''; sys.stdout.flush()
if show_automaton_gif:
outfile = spot.ofstream(imgprefix + '-a.dot')
spot.dotty_reachable(outfile, automaton)
del outfile
os.spawnlp(os.P_WAIT, 'dot', 'dot', '-Tgif', '-Gsize=14,14', '-o',
imgprefix + '-a.gif', imgprefix + '-a.dot')
os.spawnlp(os.P_WAIT, 'convert', 'convert',
imgprefix + '-a.gif', imgprefix + '-a.png')
print '
'
if show_degen_dot or show_degen_gif:
print ''; sys.stdout.flush() s = spot.ostringstream() spot.dotty_reachable(s, degen) print cgi.escape(s.str()) del s print ''; sys.stdout.flush() if show_degen_gif: outfile = spot.ofstream(imgprefix + '-d.dot') spot.dotty_reachable(outfile, degen) del outfile os.spawnlp(os.P_WAIT, 'dot', 'dot', '-Tgif', '-Gsize=14,14', '-o', imgprefix + '-d.gif', imgprefix + '-d.dot') os.spawnlp(os.P_WAIT, 'convert', 'convert', imgprefix + '-d.gif', imgprefix + '-d.png') print '
'
else:
degen = 0
if show_dictionnay:
print ''
sys.stdout.flush()
automaton.get_dict().dump(spot.get_cout())
print ''
if (type(automaton) == spot.tgba_bdd_concretePtr
and (show_relation_dot or show_relation_set or show_relation_gif)):
print '
'
if (type(automaton) == spot.tgba_bdd_concretePtr
and (show_acceptance_dot or show_acceptance_set or show_acceptance_gif)):
print '
'
if show_lbtt:
print ''
sys.stdout.flush()
spot.lbtt_reachable(spot.get_cout(), automaton)
print ''
if degen:
print '' sys.stdout.flush() spot.lbtt_reachable(spot.get_cout(), degen) print '' sys.stdout.flush() spot.destroy(f) # Make sure degen is cleared before automaton. del degen del automaton print '