From 17f4f34d23f4bc78941ee947658e2d0e6a8c65fd Mon Sep 17 00:00:00 2001 From: ccremers Date: Thu, 23 Nov 2006 11:28:51 +0000 Subject: [PATCH] - Improved locating binaries etc. --- gui/Gui/Settingswindow.py | 4 +- gui/Scyther/Scyther.py | 81 ++++++++++++++++++++++----------------- gui/Scyther/__init__.py | 4 +- src/copy2ecss.sh | 15 -------- src/copy2gui.sh | 4 ++ 5 files changed, 55 insertions(+), 53 deletions(-) delete mode 100755 src/copy2ecss.sh create mode 100755 src/copy2gui.sh diff --git a/gui/Gui/Settingswindow.py b/gui/Gui/Settingswindow.py index cbd75d5..b9fb4c6 100644 --- a/gui/Gui/Settingswindow.py +++ b/gui/Gui/Settingswindow.py @@ -77,8 +77,8 @@ class SettingsWindow(wx.Panel): ### MISC expert stuff grid.titleAdd("Advanced parameters") - # Bound on the number of classes/attacks - self.maxattacks = int(Preference.get('maxattacks','100')) + # Bound on the number of patterns + self.maxattacks = int(Preference.get('maxattacks','10')) stname = Claim.stateDescription(True,2,False) atname = Claim.stateDescription(False,2,False) txt = "%s/%s" % (stname,atname) diff --git a/gui/Scyther/Scyther.py b/gui/Scyther/Scyther.py index e843c5c..aafb99c 100755 --- a/gui/Scyther/Scyther.py +++ b/gui/Scyther/Scyther.py @@ -19,10 +19,10 @@ from Misc import * #--------------------------------------------------------------------------- -""" Globals """ -bindir="../Bin" - -#--------------------------------------------------------------------------- +""" +The default path for the binaries is set in __init__.py in the (current) +directory 'Scyther'. +""" def setBinDir(dir): global bindir @@ -36,41 +36,48 @@ def getBinDir(): #--------------------------------------------------------------------------- +def getScytherBackend(): + # Where is my executable? + # + # Auto-detect platform and infer executable name from that + # + if "linux" in sys.platform: + + """ linux """ + scythername = "scyther-linux" + + elif "darwin" in sys.platform: + + """ OS X """ + # Preferably, we test for architecture (PPC/Intel) until we + # know how to build a universal binary + scythername = "scyther-osx" + + elif sys.platform.startswith('win'): + + """ Windows """ + scythername = "Scyther.exe" + + else: + + """ Unsupported""" + print "ERROR: I'm sorry, the %s platform is unsupported at the moment" % (sys.platform) + sys.exit() + + program = os.path.join(getBinDir(),scythername) + if not os.path.isfile(program): + print "I can't find the Scyther executable at %s" % (program) + return None + + return program + +#--------------------------------------------------------------------------- + class Scyther(object): def __init__ ( self): - global bindir - - # Where is my executable? - # - # Auto-detect platform and infer executable name from that - # - prefix = os.path.abspath(bindir) - if "linux" in sys.platform: - - """ linux """ - self.program = os.path.join(prefix,"scyther") - - elif "darwin" in sys.platform: - - """ OS X """ - # Preferably, we test for architecture (PPC/Intel) until we - # know how to build a universal binary - self.program = os.path.join(prefix,"scyther-osx") - - elif sys.platform.startswith('win'): - - """ Windows """ - # TODO hardcoded for now, bad - self.program = os.path.join(prefix,"Scyther.exe") - if not os.path.isfile(self.program): - print "I can't find the Scyther executable at %s" % (self.program) - else: - - """ Unsupported""" - print "ERROR: I'm sorry, the %s platform is unsupported at the moment" % (sys.platform) - sys.exit() # Init + self.program = getScytherBackend() self.spdl = None self.inputfile = None self.options = "" @@ -105,6 +112,10 @@ class Scyther(object): fp.close() def verify(self): + """ Should return a list of results """ + + if self.program == None: + return [] # Run Scyther on temp file self.cmd = "\"%s\"" % self.program diff --git a/gui/Scyther/__init__.py b/gui/Scyther/__init__.py index 7e32c73..b123ebf 100644 --- a/gui/Scyther/__init__.py +++ b/gui/Scyther/__init__.py @@ -5,5 +5,7 @@ # order to correctly find the executables # import Scyther +import os.path -Scyther.setBinDir(__path__[0]) +bindir = os.path.join(__path__[0],"..","Bin") +Scyther.setBinDir(bindir) diff --git a/src/copy2ecss.sh b/src/copy2ecss.sh deleted file mode 100755 index 8581e59..0000000 --- a/src/copy2ecss.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -SVNDIR=https://svn.win.tue.nl/repos/ecss/trunk/protocols/spdl/scyther -TMPDIR=/tmp/ecsslatesscyther -VERSIONFILE=$TMPDIR/version.txt -SCYTHER=$TMPDIR/scyther - -rm -rf $TMPDIR -svn co $SVNDIR $TMPDIR -cp scyther $SCYTHER -$SCYTHER --version >$VERSIONFILE -cat $VERSIONFILE -svn commit --file $VERSIONFILE $SCYTHER - -echo "Committed this version to the ECSS repository." diff --git a/src/copy2gui.sh b/src/copy2gui.sh new file mode 100755 index 0000000..3dc48bb --- /dev/null +++ b/src/copy2gui.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +cp scyther-linux ../gui/Bin +