- Some standalone things.
This commit is contained in:
parent
e1ddf0668b
commit
88990f93bb
@ -38,14 +38,15 @@ class Scyther(object):
|
|||||||
|
|
||||||
def verify(self):
|
def verify(self):
|
||||||
|
|
||||||
|
# Run Scyther on temp file
|
||||||
|
self.cmd = "%s --dot-output --xml-output --plain %s" % (self.program,self.options)
|
||||||
|
|
||||||
if self.spdl:
|
if self.spdl:
|
||||||
# Write spdl to temp file
|
# Write spdl to temp file
|
||||||
fp = tempfile.NamedTemporaryFile()
|
fp = tempfile.NamedTemporaryFile()
|
||||||
fp.write(self.spdl)
|
fp.write(self.spdl)
|
||||||
fp.flush()
|
fp.flush()
|
||||||
|
self.cmd += " '%s'" % (fp.name)
|
||||||
# Run Scyther on temp file
|
|
||||||
self.cmd = "%s %s --dot-output --xml-output --plain '%s'" % (self.program,self.options,fp.name)
|
|
||||||
|
|
||||||
# If we are on windows, we don't get stderr. Maybe we need a
|
# If we are on windows, we don't get stderr. Maybe we need a
|
||||||
# switch to enforce this.
|
# switch to enforce this.
|
||||||
@ -56,26 +57,18 @@ class Scyther(object):
|
|||||||
cmdline = "%s" % (self.cmd)
|
cmdline = "%s" % (self.cmd)
|
||||||
|
|
||||||
result = os.popen(cmdline)
|
result = os.popen(cmdline)
|
||||||
|
|
||||||
xmlinput = result.read()
|
xmlinput = result.read()
|
||||||
|
result.close()
|
||||||
|
|
||||||
|
if self.spdl:
|
||||||
fp.close()
|
fp.close()
|
||||||
|
|
||||||
xmlfile = StringIO.StringIO(xmlinput)
|
xmlfile = StringIO.StringIO(xmlinput)
|
||||||
reader = XMLReader.XMLReader()
|
reader = XMLReader.XMLReader()
|
||||||
self.claims = reader.readXML(xmlfile)
|
self.claims = reader.readXML(xmlfile)
|
||||||
|
|
||||||
|
|
||||||
# Cleanup
|
|
||||||
del(xmlinput)
|
|
||||||
del(xmlfile)
|
|
||||||
return self.claims
|
return self.claims
|
||||||
|
|
||||||
else:
|
|
||||||
# No input yet!
|
|
||||||
return ""
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.claims:
|
if self.claims:
|
||||||
s = ""
|
s = ""
|
||||||
@ -105,8 +98,16 @@ def basictest():
|
|||||||
|
|
||||||
x.setFile("ns3.spdl")
|
x.setFile("ns3.spdl")
|
||||||
x.verify()
|
x.verify()
|
||||||
|
print x
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
pars = sys.argv[1:]
|
||||||
|
if len(pars) == 0:
|
||||||
basictest()
|
basictest()
|
||||||
|
else:
|
||||||
|
x = Scyther()
|
||||||
|
x.options = " ".join(pars)
|
||||||
|
x.verify()
|
||||||
|
print x
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user