- Improved dot output significantly
This commit is contained in:
parent
e297182730
commit
9326426a55
@ -78,7 +78,7 @@ class AttackDisplay(wx.ScrolledWindow):
|
|||||||
if self.attack.filetype == "png":
|
if self.attack.filetype == "png":
|
||||||
bmp = self.original
|
bmp = self.original
|
||||||
if not bmp.Ok():
|
if not bmp.Ok():
|
||||||
bmp = wx.EmptyBitmap((1,1))
|
bmp = wx.EmptyImage(1,1)
|
||||||
else:
|
else:
|
||||||
(W,H) = (bmp.GetWidth(), bmp.GetHeight())
|
(W,H) = (bmp.GetWidth(), bmp.GetHeight())
|
||||||
if self.win.fit:
|
if self.win.fit:
|
||||||
|
@ -58,8 +58,8 @@ class MainWindow(wx.Frame):
|
|||||||
self.CreateExteriorWindowComponents()
|
self.CreateExteriorWindowComponents()
|
||||||
|
|
||||||
aTable = wx.AcceleratorTable([
|
aTable = wx.AcceleratorTable([
|
||||||
#(wx.ACCEL_ALT, ord('X'), exitID),
|
(wx.ACCEL_ALT, ord('X'), wx.ID_EXIT),
|
||||||
(wx.ACCEL_CTRL, ord('W'), wx.ID_EXIT),
|
(wx.ACCEL_CTRL, ord('Q'), wx.ID_EXIT),
|
||||||
(wx.ACCEL_NORMAL, wx.WXK_F1,
|
(wx.ACCEL_NORMAL, wx.WXK_F1,
|
||||||
ID_VERIFY),
|
ID_VERIFY),
|
||||||
(wx.ACCEL_NORMAL, wx.WXK_F2,
|
(wx.ACCEL_NORMAL, wx.WXK_F2,
|
||||||
@ -134,7 +134,7 @@ class MainWindow(wx.Frame):
|
|||||||
(wx.ID_SAVEAS, 'Save &As', 'Save the file under a different name',
|
(wx.ID_SAVEAS, 'Save &As', 'Save the file under a different name',
|
||||||
self.OnSaveAs),
|
self.OnSaveAs),
|
||||||
(None, None, None, None),
|
(None, None, None, None),
|
||||||
(wx.ID_EXIT, 'E&xit\tCTRL-W', 'Terminate the program',
|
(wx.ID_EXIT, 'E&xit\tCTRL-Q', 'Terminate the program',
|
||||||
self.OnExit)])
|
self.OnExit)])
|
||||||
self.CreateMenu(menuBar, '&Verify',
|
self.CreateMenu(menuBar, '&Verify',
|
||||||
[(ID_VERIFY, '&Verify protocol\tF1','Verify the protocol in the buffer using Scyther',
|
[(ID_VERIFY, '&Verify protocol\tF1','Verify the protocol in the buffer using Scyther',
|
||||||
|
@ -109,6 +109,62 @@ class AttackThread(threading.Thread):
|
|||||||
if self.callbackdone:
|
if self.callbackdone:
|
||||||
wx.CallAfter(self.callbackdone)
|
wx.CallAfter(self.callbackdone)
|
||||||
|
|
||||||
|
def writeGraph(self,txt,fp):
|
||||||
|
|
||||||
|
def graphLine(txt):
|
||||||
|
fp.write("\t%s;\n" % (txt))
|
||||||
|
|
||||||
|
def setAttr(EdgeNodeDefAll,atxt):
|
||||||
|
if EdgeNodeDefAll == 3:
|
||||||
|
setAttr(0,atxt)
|
||||||
|
setAttr(1,atxt)
|
||||||
|
setAttr(2,atxt)
|
||||||
|
else:
|
||||||
|
if EdgeNodeDefAll == 0:
|
||||||
|
edge = "edge"
|
||||||
|
elif EdgeNodeDefAll == 1:
|
||||||
|
edge = "node"
|
||||||
|
else:
|
||||||
|
graphLine("%s" % atxt)
|
||||||
|
return
|
||||||
|
graphLine("%s [%s]" % (edge,atxt))
|
||||||
|
|
||||||
|
def oldFontDefs(txt):
|
||||||
|
"""
|
||||||
|
Old hack. Remove after windows recompile TODO
|
||||||
|
"""
|
||||||
|
if txt.startswith("\tfontname"):
|
||||||
|
return True
|
||||||
|
if txt.startswith("\tfontsize"):
|
||||||
|
return True
|
||||||
|
if txt.startswith("\tnode [fontname"):
|
||||||
|
return True
|
||||||
|
if txt.startswith("\tnode [fontsize"):
|
||||||
|
return True
|
||||||
|
if txt.startswith("\tedge [fontname"):
|
||||||
|
return True
|
||||||
|
if txt.startswith("\tedge [fontsize"):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
for l in txt.splitlines():
|
||||||
|
# hack to get rid of font defs
|
||||||
|
# TODO remove this once new windows version is compiled
|
||||||
|
if not oldFontDefs(l):
|
||||||
|
fp.write(l)
|
||||||
|
if l.startswith("digraph"):
|
||||||
|
# Write additional stuff for this graph
|
||||||
|
graphLine("rankdir=TB")
|
||||||
|
graphLine("nodesep=0.1")
|
||||||
|
graphLine("ranksep=0.001")
|
||||||
|
graphLine("mindist=0.1")
|
||||||
|
setAttr(3,"fontname=Sans")
|
||||||
|
setAttr(3,"fontsize=10")
|
||||||
|
setAttr(1,"height=\"0.01\"")
|
||||||
|
setAttr(1,"width=\"0.01\"")
|
||||||
|
setAttr(1,"margin=\"0.08,0.03\"")
|
||||||
|
#setAttr(0,"decorate=true")
|
||||||
|
|
||||||
def makeImage(self,attack):
|
def makeImage(self,attack):
|
||||||
""" create image for this particular attack """
|
""" create image for this particular attack """
|
||||||
if Preference.usePIL():
|
if Preference.usePIL():
|
||||||
@ -124,11 +180,13 @@ class AttackThread(threading.Thread):
|
|||||||
# command to write to temporary file
|
# command to write to temporary file
|
||||||
(fd2,fpname2) = Tempfile.tempcleaned(ext)
|
(fd2,fpname2) = Tempfile.tempcleaned(ext)
|
||||||
f = os.fdopen(fd2,'w')
|
f = os.fdopen(fd2,'w')
|
||||||
|
|
||||||
cmd = "dot -T%s" % (type)
|
cmd = "dot -T%s" % (type)
|
||||||
|
|
||||||
# execute command
|
# execute command
|
||||||
cin,cout = os.popen2(cmd,'b')
|
cin,cout = os.popen2(cmd,'b')
|
||||||
cin.write(attack.scytherDot)
|
|
||||||
|
self.writeGraph(attack.scytherDot,cin)
|
||||||
cin.close()
|
cin.close()
|
||||||
|
|
||||||
for l in cout.read():
|
for l in cout.read():
|
||||||
|
Loading…
Reference in New Issue
Block a user