- Switched to popen2, hopefully solving some of the tempfile issues.
This commit is contained in:
parent
ccaa6e9197
commit
5ab90bdabf
@ -44,16 +44,6 @@ class Scyther(object):
|
|||||||
# Run Scyther on temp file
|
# Run Scyther on temp file
|
||||||
self.cmd = "%s --dot-output --xml-output --plain %s" % (self.program,self.options)
|
self.cmd = "%s --dot-output --xml-output --plain %s" % (self.program,self.options)
|
||||||
|
|
||||||
if self.spdl:
|
|
||||||
if self.inputfile:
|
|
||||||
fp = open(self.inputfile,'r')
|
|
||||||
else:
|
|
||||||
# Write spdl to temp file
|
|
||||||
fp = tempfile.NamedTemporaryFile()
|
|
||||||
fp.write(self.spdl)
|
|
||||||
fp.flush()
|
|
||||||
self.cmd += " %s" % (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.
|
||||||
if sys.platform.startswith('linux'):
|
if sys.platform.startswith('linux'):
|
||||||
@ -62,18 +52,12 @@ class Scyther(object):
|
|||||||
# Non-linux does not generate stderr anyway
|
# Non-linux does not generate stderr anyway
|
||||||
cmdline = "%s" % (self.cmd)
|
cmdline = "%s" % (self.cmd)
|
||||||
|
|
||||||
print cmdline
|
pw,pr = os.popen2(cmdline)
|
||||||
confirm("Run this command?")
|
|
||||||
|
|
||||||
result = os.popen(cmdline)
|
|
||||||
xmlinput = result.read()
|
|
||||||
result.close()
|
|
||||||
|
|
||||||
print xmlinput
|
|
||||||
confirm("Is this the correct output?")
|
|
||||||
|
|
||||||
if self.spdl:
|
if self.spdl:
|
||||||
fp.close()
|
pw.write(self.spdl)
|
||||||
|
pw.close()
|
||||||
|
xmlinput = pr.read()
|
||||||
|
pr.close()
|
||||||
|
|
||||||
xmlfile = StringIO.StringIO(xmlinput)
|
xmlfile = StringIO.StringIO(xmlinput)
|
||||||
reader = XMLReader.XMLReader()
|
reader = XMLReader.XMLReader()
|
||||||
@ -107,9 +91,9 @@ def basicTest():
|
|||||||
x.program = "Scyther.exe"
|
x.program = "Scyther.exe"
|
||||||
if not os.path.isfile(x.program):
|
if not os.path.isfile(x.program):
|
||||||
print "I can't find the Scyther executable %s" % (x.program)
|
print "I can't find the Scyther executable %s" % (x.program)
|
||||||
else:
|
pw,pr = os.popen2("%s --help" % x.program)
|
||||||
p = os.popen("%s --help" % x.program)
|
pw.close()
|
||||||
print p.read()
|
print pr.read()
|
||||||
confirm("Do you see the help?")
|
confirm("Do you see the help?")
|
||||||
|
|
||||||
x.setFile("ns3.spdl")
|
x.setFile("ns3.spdl")
|
||||||
|
Loading…
Reference in New Issue
Block a user