2006-08-02 13:59:57 +01:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
""" Import externals """
|
|
|
|
import wx
|
2006-08-07 12:02:14 +01:00
|
|
|
import sys
|
2006-08-08 18:04:26 +01:00
|
|
|
import os
|
2006-08-07 16:06:10 +01:00
|
|
|
from optparse import OptionParser, SUPPRESS_HELP
|
2006-08-02 13:59:57 +01:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
""" Import scyther-gui components """
|
2006-08-08 16:54:00 +01:00
|
|
|
import Gui.Preference as Preference
|
|
|
|
import Gui.Mainwindow as Mainwindow
|
|
|
|
import Gui.Misc as Misc
|
2006-08-09 10:26:15 +01:00
|
|
|
import Scyther.Scyther as Scyther
|
2006-08-02 13:59:57 +01:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
2006-08-07 13:59:22 +01:00
|
|
|
def parseArgs():
|
2006-08-07 16:06:10 +01:00
|
|
|
usage = "usage: %s [options] [inputfile]" % sys.argv[0]
|
|
|
|
description = "scyther-gui is a graphical user interface for the scyther protocol verification tool."
|
|
|
|
parser = OptionParser(usage=usage,description=description)
|
2006-08-07 13:59:22 +01:00
|
|
|
|
|
|
|
# command
|
2006-08-07 16:06:10 +01:00
|
|
|
parser.add_option("-V","--verify",dest="command",default=None,action="store_const",const="verify",
|
|
|
|
help="Immediately verify the claims of the protocol (requires input file)")
|
|
|
|
parser.add_option("-s","--state-space",dest="command",default=None,action="store_const",const="statespace",
|
|
|
|
help="Immediately generate the complete characterization of the protocol (requires input file)")
|
|
|
|
parser.add_option("-a","--auto-claims",dest="command",default=None,action="store_const",const="autoverify",
|
|
|
|
help="Immediately verified protocol using default claims (requires input file)")
|
|
|
|
parser.add_option("-c","--check",dest="command",default=None,action="store_const",const="check",
|
|
|
|
help="Immediately check protocol (requires input file)")
|
2006-08-07 13:59:22 +01:00
|
|
|
|
2006-08-07 16:06:10 +01:00
|
|
|
# misc debug etc (not shown in the --help output)
|
|
|
|
parser.add_option("","--test",dest="test",default=False,action="store_true",
|
|
|
|
help=SUPPRESS_HELP)
|
2006-08-07 13:59:22 +01:00
|
|
|
|
|
|
|
return parser.parse_args()
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
2006-08-02 13:59:57 +01:00
|
|
|
class MySplashScreen(wx.SplashScreen):
|
|
|
|
def __init__(self):
|
2006-08-08 18:07:15 +01:00
|
|
|
bmp = wx.Image(os.path.join("Images","scyther-splash.png")).ConvertToBitmap()
|
2006-08-02 13:59:57 +01:00
|
|
|
wx.SplashScreen.__init__(self, bmp,
|
|
|
|
wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT,
|
|
|
|
5000, None, -1)
|
|
|
|
self.Bind(wx.EVT_CLOSE, self.OnClose)
|
|
|
|
self.fc = wx.FutureCall(2000, self.ShowMain)
|
|
|
|
|
|
|
|
def OnClose(self, evt):
|
|
|
|
# Make sure the default handler runs too so this window gets
|
|
|
|
# destroyed
|
|
|
|
evt.Skip()
|
|
|
|
self.Hide()
|
|
|
|
|
|
|
|
# if the timer is still running then go ahead and show the
|
|
|
|
# main frame now
|
|
|
|
if self.fc.IsRunning():
|
|
|
|
self.fc.Stop()
|
|
|
|
self.ShowMain()
|
|
|
|
|
|
|
|
|
|
|
|
def ShowMain(self):
|
|
|
|
if self.fc.IsRunning():
|
|
|
|
self.Raise()
|
|
|
|
|
|
|
|
|
2006-08-07 13:59:22 +01:00
|
|
|
#---------------------------------------------------------------------------
|
2006-08-02 13:59:57 +01:00
|
|
|
|
|
|
|
class ScytherApp(wx.App):
|
|
|
|
def OnInit(self):
|
|
|
|
|
2006-08-02 23:44:10 +01:00
|
|
|
wx.GetApp().SetAppName("Scyther-gui")
|
|
|
|
|
2006-08-07 13:59:22 +01:00
|
|
|
# Parse arguments
|
2006-08-09 10:26:15 +01:00
|
|
|
basedir = os.path.abspath(os.path.dirname(sys.argv[0]))
|
2006-08-07 13:59:22 +01:00
|
|
|
(opts,args) = parseArgs()
|
2006-08-02 13:59:57 +01:00
|
|
|
|
2006-08-07 13:59:22 +01:00
|
|
|
# Load preferences file
|
2006-08-02 13:59:57 +01:00
|
|
|
Preference.init()
|
|
|
|
|
2006-08-09 10:26:15 +01:00
|
|
|
# Init Scyther libs
|
|
|
|
bindir = Preference.get("bindir",os.path.join(basedir,"Scyther"))
|
|
|
|
Scyther.init(bindir)
|
|
|
|
|
2006-08-02 13:59:57 +01:00
|
|
|
"""
|
|
|
|
Create and show the splash screen. It will then create and show
|
|
|
|
the main frame when it is time to do so.
|
2006-08-07 13:59:22 +01:00
|
|
|
|
|
|
|
The splash screen is disabled for automatic commands, and also
|
|
|
|
by a setting in the preferences file.
|
2006-08-02 13:59:57 +01:00
|
|
|
"""
|
2006-08-07 13:59:22 +01:00
|
|
|
if not opts.command:
|
|
|
|
if not (Preference.get('splashscreen') in ['false','off','disable','0']):
|
|
|
|
splash = MySplashScreen()
|
|
|
|
splash.Show()
|
2006-08-02 13:59:57 +01:00
|
|
|
|
2006-08-07 13:59:22 +01:00
|
|
|
self.mainWindow = Mainwindow.MainWindow(opts,args)
|
2006-08-02 13:59:57 +01:00
|
|
|
self.SetTopWindow(self.mainWindow)
|
|
|
|
self.mainWindow.Show()
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
def OnExit(self):
|
|
|
|
""" Tear down """
|
|
|
|
|
2006-08-08 18:07:15 +01:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2006-08-02 13:59:57 +01:00
|
|
|
if __name__ == '__main__':
|
|
|
|
scythergui = ScytherApp()
|
|
|
|
scythergui.MainLoop()
|
|
|
|
|
|
|
|
|