From 1f75f73cb0dbb2654c1fe80cf410fd5e7f5db7ba Mon Sep 17 00:00:00 2001 From: Cas Cremers Date: Sat, 15 May 2010 23:27:11 +0200 Subject: [PATCH] Added realistic check for graphviz/dot. --- gui/scyther-gui.py | 57 +++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/gui/scyther-gui.py b/gui/scyther-gui.py index 81bc5a5..42da9c8 100755 --- a/gui/scyther-gui.py +++ b/gui/scyther-gui.py @@ -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 sys @@ -48,7 +36,7 @@ try: import wx except ImportError: - panic(""" + Misc.panic(""" ERROR: 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 from optparse import OptionParser, SUPPRESS_HELP - -#--------------------------------------------------------------------------- - -""" Import scyther-gui components """ -from Gui import About,Preference,Mainwindow,Misc -from Scyther import Scyther +from subprocess import * #--------------------------------------------------------------------------- @@ -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__': + CheckRequirements() scythergui = ScytherApp() scythergui.MainLoop()