Added realistic check for graphviz/dot.

This commit is contained in:
Cas Cremers 2010-05-15 23:27:11 +02:00
parent 7d03f22b24
commit 1f75f73cb0

View File

@ -21,26 +21,14 @@
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
def panic(text):
"""
Errors that occur before we even are sure about wxPython etc. are dumped
on the command line and reported using Tkinter.
"""
import Tkinter
print text
root = Tkinter.Tk()
w = Tkinter.Label(root, text=text)
w.pack()
root.mainloop()
sys.exit(-1)
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
""" Import scyther-gui components """
from Gui import About,Preference,Mainwindow
from Scyther import Scyther,Misc
#---------------------------------------------------------------------------
""" Import externals """ """ Import externals """
import sys import sys
@ -48,7 +36,7 @@ try:
import wx import wx
except ImportError: except ImportError:
panic(""" Misc.panic("""
ERROR: ERROR:
Could not find the required [wxPython] package. Could not find the required [wxPython] package.
@ -64,12 +52,7 @@ Note that you can still use the Scyther binaries in the 'Scyther' directory.
import os import os
from optparse import OptionParser, SUPPRESS_HELP from optparse import OptionParser, SUPPRESS_HELP
from subprocess import *
#---------------------------------------------------------------------------
""" Import scyther-gui components """
from Gui import About,Preference,Mainwindow,Misc
from Scyther import Scyther
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@ -192,8 +175,34 @@ class ScytherApp(wx.App):
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
def CheckRequirements():
""" Check for any required programs """
""" We need 'dot', in the graphviz package """
failed = False
try:
(sts,sout,serr) = Misc.safeCommandOutput("dot -V")
output = (sout + serr).lower()
if output.find("graphviz") == -1:
failed = True
except OSError, ImportError:
failed = True
if failed:
Misc.panic("""
Could not find the required 'dot' program, which is part of the graphviz suite.
Please install it from http://www.graphviz.org/
Ubuntu users: install the 'graphviz' package.
Restarting your system may be needed for Scyther to locate any newly installed
programs.
""")
#---------------------------------------------------------------------------
if __name__ == '__main__': if __name__ == '__main__':
CheckRequirements()
scythergui = ScytherApp() scythergui = ScytherApp()
scythergui.MainLoop() scythergui.MainLoop()