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