Updated image construction code to also use subprocess.Popen.

This commit is contained in:
Cas Cremers 2010-05-16 00:13:33 +02:00
parent 1f75f73cb0
commit d1b334765b
2 changed files with 13 additions and 7 deletions

View File

@ -25,10 +25,12 @@
import wx
import os
import sys
from subprocess import Popen, PIPE
#---------------------------------------------------------------------------
""" Import scyther components """
from Scyther import Misc as MiscScyther
""" Import scyther-gui components """
import Temporary
@ -126,22 +128,23 @@ def makeImageDot(dotdata,attackthread=None):
(fd2,fpname2) = Temporary.tempcleaned(ext)
f = os.fdopen(fd2,'w')
# Set up command
cmd = "dot -T%s" % (type)
# execute command
cin,cout = os.popen2(cmd,'b')
p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE)
if attackthread:
writeGraph(attackthread,dotdata,cin)
writeGraph(attackthread,dotdata,p.stdin)
else:
cin.write(dotdata)
p.stdin.write(dotdata)
cin.close()
p.stdin.close()
for l in cout.read():
for l in p.stdout.read():
f.write(l)
cout.close()
p.stdout.close()
f.flush()
f.close()

View File

@ -25,6 +25,7 @@
""" Import externals """
import os.path
from subprocess import Popen,PIPE
#---------------------------------------------------------------------------
@ -70,7 +71,9 @@ def cmdpushwrite(cmd,data,fname):
"""
fp = open(fname,'w')
# execute command
cin,cout = os.popen2(cmd,'b')
p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE)
(cin,cout) = (p.stdin, p.stdout)
cin.write(data)
cin.close()
for l in cout.read():