- Some standalone things.
This commit is contained in:
parent
e1ddf0668b
commit
88990f93bb
@ -38,43 +38,36 @@ 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
|
# If we are on windows, we don't get stderr. Maybe we need a
|
||||||
self.cmd = "%s %s --dot-output --xml-output --plain '%s'" % (self.program,self.options,fp.name)
|
# switch to enforce this.
|
||||||
|
if sys.platform.startswith('linux'):
|
||||||
# If we are on windows, we don't get stderr. Maybe we need a
|
cmdline = "%s 2>/dev/null" % (self.cmd)
|
||||||
# switch to enforce this.
|
else:
|
||||||
if sys.platform.startswith('linux'):
|
# Non-linux does not generate stderr anyway
|
||||||
cmdline = "%s 2>/dev/null" % (self.cmd)
|
cmdline = "%s" % (self.cmd)
|
||||||
else:
|
|
||||||
# Non-linux does not generate stderr anyway
|
|
||||||
cmdline = "%s" % (self.cmd)
|
|
||||||
|
|
||||||
result = os.popen(cmdline)
|
|
||||||
|
|
||||||
xmlinput = result.read()
|
|
||||||
|
|
||||||
|
result = os.popen(cmdline)
|
||||||
|
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)
|
||||||
|
|
||||||
|
return self.claims
|
||||||
# Cleanup
|
|
||||||
del(xmlinput)
|
|
||||||
del(xmlfile)
|
|
||||||
return self.claims
|
|
||||||
|
|
||||||
else:
|
|
||||||
# No input yet!
|
|
||||||
return ""
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.claims:
|
if self.claims:
|
||||||
@ -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__':
|
||||||
basictest()
|
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