Further Python3 fixes.

This commit is contained in:
Cas Cremers 2020-10-27 22:10:55 +01:00
parent 3a6041ccac
commit 38a0fba212
5 changed files with 20 additions and 15 deletions

View File

@ -53,7 +53,7 @@ def writeGraph(attackthread,txt,fp):
ALL = 3
def graphLine(txt):
fp.write("\t%s;\n" % (txt))
fp.write(("\t%s;\n" % (txt)).encode('utf-8'))
def setAttr(atxt,EdgeNodeDefAll=ALL):
if EdgeNodeDefAll == ALL:
@ -81,7 +81,7 @@ def writeGraph(attackthread,txt,fp):
# write all graph lines but add layout modifiers
for l in txt.splitlines():
fp.write(l)
fp.write(l.encode('utf-8'))
if l.startswith("digraph"):
# Write additional stuff for this graph
#
@ -147,7 +147,7 @@ def makeImageDot(dotdata,attackthread=None):
p.stdin.close()
for l in p.stdout.read():
f.write(l)
f.write(str(l))
p.stdout.close()
f.flush()

View File

@ -41,8 +41,9 @@ def testDot(fpath):
try:
cmd = "%s -V" % (fpath)
(sts,sout,serr) = Misc.safeCommandOutput(cmd)
if sts != -1:
if "version" in sout + serr:
if "version" in str(sout) + str(serr):
return True
except:
pass

View File

@ -294,14 +294,18 @@ class Scyther(object):
# Apparently we are supporsed to be able to use the cache
m = hashlib.sha256()
def muppet(m, s):
m.update(s.encode('utf-8'))
if spdl == None:
m.update("[spdl:None]")
muppet(m, "[spdl:None]")
else:
m.update(spdl)
muppet(m, spdl)
if args == None:
m.update("[args:None]")
muppet(m, "[args:None]")
else:
m.update(args)
muppet(m, args)
uid = m.hexdigest()
@ -399,7 +403,7 @@ class Scyther(object):
(fdi,fni) = tempfile.mkstemp() # input
# Write (input) file
fhi = os.fdopen(fdi,'w+b')
fhi = os.fdopen(fdi,'w+')
fhi.write(spdl)
fhi.close()
@ -495,7 +499,7 @@ class Scyther(object):
# whoohee, xml
self.validxml = True
xmlfile = StringIO.StringIO(output)
xmlfile = io.StringIO(output)
reader = XMLReader.XMLReader()
self.claims = reader.readXML(xmlfile)
@ -595,10 +599,10 @@ def FindProtocols(path="",filterProtocol=None):
Note: Unix only! Will not work under windows.
"""
import commands
import subprocess
cmd = "find %s -iname '*.spdl'" % (path)
plist = commands.getoutput(cmd).splitlines()
plist = subprocess.getoutput(cmd).splitlines()
nlist = []
for prot in plist:
if filterProtocol != None:

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
"""
Scyther : An automatic verifier for security protocols.
Copyright (C) 2007-2013 Cas Cremers
@ -193,7 +193,7 @@ class ScytherApp(wx.App):
# License option may abort here
if opts.license:
print Scyther.GetLicense()
print(Scyther.GetLicense())
sys.exit(0)
# Load preferences file

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Scyther : An automatic verifier for security protocols.
Copyright (C) 2007-2013 Cas Cremers