From 57639c70dddcfb7d2fa296a123a62a2202862df2 Mon Sep 17 00:00:00 2001 From: ccremers Date: Wed, 2 Aug 2006 21:15:36 +0000 Subject: [PATCH] - Some improvements to image computation code. --- gui/Scytherthread.py | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/gui/Scytherthread.py b/gui/Scytherthread.py index 9194ee7..8197f98 100644 --- a/gui/Scytherthread.py +++ b/gui/Scytherthread.py @@ -31,12 +31,6 @@ busy = threading.Semaphore() #--------------------------------------------------------------------------- -def ScytherPath(): - """ Retrieve Scyther path, and maybe test whether is is valid? """ - program = Preference.get('scyther','scyther') - program = "\\\\Roivas\\public\\scyther-gui\\Scyther.exe" - return program - class ScytherThread(threading.Thread): # Override Thread's __init__ method to accept the parameters needed: def __init__ ( self, win, spdl, details ): @@ -58,14 +52,24 @@ class ScytherThread(threading.Thread): self.claimResults() + # Results are done (claimstatus can be reported) evt = UpdateAttackEvent(status="Done.") wx.PostEvent(self.win, evt) - #self.win.SetCursor(wx.StockCursor(wx.CURSOR_ARROW)) + # And create the images in the background + self.makeImages() + + # Cursor back to normal + self.win.SetCursor(wx.StockCursor(wx.CURSOR_ARROW)) + busy.release() def claimResults(self): - """ Convert spdl to result (using Scyther) """ + """ Convert spdl to result (using Scyther) + + The list of claim goes back to self.win.claims, which is a + property of the main window + """ scyther = Scyther.Scyther() if sys.platform.startswith('win'): @@ -74,11 +78,26 @@ class ScytherThread(threading.Thread): print "I can't find the Scyther executable %s" % (scyther.program) scyther.setInput(self.spdl) - self.claims = scyther.verify() + self.win.claims = scyther.verify() self.summary = str(scyther) self.win.errors.update(self.summary) + def makeImages(self): + """ create images """ + for cl in self.win.claims: + for attack in cl.attacks: + self.makeImage(attack) + + def makeImage(self,attack): + """ create image for this particular attack """ + + (fd2,fpname2) = Tempfile.tempcleaned(".png") + pw,pr = os.popen2("dot -Tpng -o%s" % (fpname2)) + pw.write(attack.scytherDot) + pw.close() + attack.pngfile = fpname2 # this is where the file name is stored + def RunScyther(win,mode):