8 class _Popen4(subprocess.Popen):
9 """Utility class to provide a portable way to spawn a child process and
10 communicate with its stdin and combined stdout/stderr."""
12 def __init__(self, cmd):
14 shell = (sys.platform !=
"win32")
15 subprocess.Popen.__init__(self, cmd, shell=shell, stdin=subprocess.PIPE,
16 stdout=subprocess.PIPE,
17 stderr=subprocess.STDOUT)
19 def require_clean_exit(self):
20 """Make sure the child exited with a zero return code"""
23 raise IOError(
"Process failed with exit status %d" % r)
25 if sys.platform ==
'win32':
26 def _run_background(cmdline, out):
27 """Run a process in the background and direct its output to a file"""
28 print "%s > %s" % (cmdline, out)
32 p = subprocess.Popen(cmdline, shell=
False, stdout=open(out,
'w'),
33 stderr=subprocess.STDOUT)
36 except WindowsError, detail:
37 print(
"WindowsError: %s (ignored)" % detail)
41 def _run_background(cmdline, out):
42 """Run a process in the background and direct its output to a file"""
43 print "%s > %s" % (cmdline, out)
44 subprocess.Popen(cmdline, shell=
True, stdout=open(out,
'w'),
45 stderr=subprocess.STDOUT)