- Rewrite subprocess access to the newer subprocess.Popen module. This seems to work just fine for Windows XP, at least.
This commit is contained in:
parent
ef2af6b097
commit
688416a351
@ -9,6 +9,11 @@ import sys
|
|||||||
import re
|
import re
|
||||||
import threading
|
import threading
|
||||||
import StringIO
|
import StringIO
|
||||||
|
try:
|
||||||
|
from subprocess import Popen
|
||||||
|
AvailablePopen = True
|
||||||
|
except:
|
||||||
|
AvailablePopen = False
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -194,6 +199,9 @@ class AttackThread(threading.Thread):
|
|||||||
|
|
||||||
def makeImage(self,attack):
|
def makeImage(self,attack):
|
||||||
""" create image for this particular attack """
|
""" create image for this particular attack """
|
||||||
|
|
||||||
|
global AvailablePopen
|
||||||
|
|
||||||
if Preference.usePIL():
|
if Preference.usePIL():
|
||||||
# If we have the PIL library, we can do postscript! great
|
# If we have the PIL library, we can do postscript! great
|
||||||
# stuff.
|
# stuff.
|
||||||
@ -207,23 +215,25 @@ class AttackThread(threading.Thread):
|
|||||||
# command to write to temporary file
|
# command to write to temporary file
|
||||||
(fd2,fpname2) = Tempfile.tempcleaned(ext)
|
(fd2,fpname2) = Tempfile.tempcleaned(ext)
|
||||||
f = os.fdopen(fd2,'w')
|
f = os.fdopen(fd2,'w')
|
||||||
|
(fd3,fpname3) = Tempfile.tempcleaned(ext)
|
||||||
|
dotfile = os.fdopen(fd3,'w')
|
||||||
|
self.writeGraph(attack.scytherDot,dotfile)
|
||||||
|
dotfile.flush()
|
||||||
|
dotfile.seek(0)
|
||||||
|
|
||||||
cmd = "dot -T%s >%s" % (type,fpname2)
|
cmd = "dot -T%s -o%s %s" % (type,fpname2,fpname3)
|
||||||
|
|
||||||
# execute command
|
# execute command
|
||||||
cin,cout = os.popen2(cmd,'b')
|
# Start the process
|
||||||
|
if AvailablePopen:
|
||||||
self.writeGraph(attack.scytherDot,cin)
|
p = Popen(cmd, shell=False)
|
||||||
cin.flush()
|
sts = p.wait()
|
||||||
cin.close()
|
else:
|
||||||
cout.close()
|
os.system(cmd)
|
||||||
|
|
||||||
f.flush()
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
# Print
|
# Print
|
||||||
print fpname2
|
#print fpname2
|
||||||
raw_input()
|
#raw_input()
|
||||||
|
|
||||||
# if this is done, store and report
|
# if this is done, store and report
|
||||||
attack.filetype = type
|
attack.filetype = type
|
||||||
|
@ -11,6 +11,12 @@ import os.path
|
|||||||
import sys
|
import sys
|
||||||
import StringIO
|
import StringIO
|
||||||
import tempfile
|
import tempfile
|
||||||
|
try:
|
||||||
|
from subprocess import Popen
|
||||||
|
AvailablePopen = True
|
||||||
|
except:
|
||||||
|
AvailablePopen = False
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -192,6 +198,7 @@ class Scyther(object):
|
|||||||
output -- string which is the real output
|
output -- string which is the real output
|
||||||
errors -- string which captures the errors
|
errors -- string which captures the errors
|
||||||
"""
|
"""
|
||||||
|
global AvailablePopen
|
||||||
|
|
||||||
if self.program == None:
|
if self.program == None:
|
||||||
raise Error.NoBinaryError
|
raise Error.NoBinaryError
|
||||||
@ -226,7 +233,11 @@ class Scyther(object):
|
|||||||
##print self.cmd
|
##print self.cmd
|
||||||
|
|
||||||
# Start the process
|
# Start the process
|
||||||
os.system(self.cmd)
|
if AvailablePopen:
|
||||||
|
p = Popen(self.cmd, shell=False)
|
||||||
|
sts = p.wait()
|
||||||
|
else:
|
||||||
|
os.system(self.cmd)
|
||||||
|
|
||||||
# reseek
|
# reseek
|
||||||
fhe = os.fdopen(fde)
|
fhe = os.fdopen(fde)
|
||||||
|
Loading…
Reference in New Issue
Block a user