- Some improvements to image computation code.

This commit is contained in:
ccremers 2006-08-02 21:15:36 +00:00
parent 5ab90bdabf
commit 57639c70dd

View File

@ -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): class ScytherThread(threading.Thread):
# Override Thread's __init__ method to accept the parameters needed: # Override Thread's __init__ method to accept the parameters needed:
def __init__ ( self, win, spdl, details ): def __init__ ( self, win, spdl, details ):
@ -58,14 +52,24 @@ class ScytherThread(threading.Thread):
self.claimResults() self.claimResults()
# Results are done (claimstatus can be reported)
evt = UpdateAttackEvent(status="Done.") evt = UpdateAttackEvent(status="Done.")
wx.PostEvent(self.win, evt) 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() busy.release()
def claimResults(self): 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() scyther = Scyther.Scyther()
if sys.platform.startswith('win'): if sys.platform.startswith('win'):
@ -74,11 +78,26 @@ class ScytherThread(threading.Thread):
print "I can't find the Scyther executable %s" % (scyther.program) print "I can't find the Scyther executable %s" % (scyther.program)
scyther.setInput(self.spdl) scyther.setInput(self.spdl)
self.claims = scyther.verify() self.win.claims = scyther.verify()
self.summary = str(scyther) self.summary = str(scyther)
self.win.errors.update(self.summary) 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): def RunScyther(win,mode):