Merge pull request #17 from dzuelke/streamsnobuffer

Don't buffer streams and fix stderr
This commit is contained in:
2016-02-16 16:28:25 -05:00
2 changed files with 5 additions and 6 deletions
+1 -2
View File
@@ -128,8 +128,7 @@ class Formula(object):
if p.returncode != 0:
print
print 'ERROR: An error occurred:'
pipe(p.stderr, sys.stderr, indent=True)
print 'ERROR: An error occurred.'
exit(1)
+4 -4
View File
@@ -3,7 +3,7 @@
import os
import re
import tarfile
from subprocess import Popen, PIPE
from subprocess import Popen, PIPE, STDOUT
def iter_marker_lines(marker, formula, strip=True):
"""Extracts any markers from a given formula."""
@@ -27,15 +27,15 @@ def mkdir_p(path):
def process(cmd, cwd=None):
"""A simple wrapper around the subprocess module."""
p = Popen(cmd, cwd=cwd, shell=False, stdout=PIPE, stderr=PIPE)
"""A simple wrapper around the subprocess module; stderr is redirected to stdout."""
p = Popen(cmd, cwd=cwd, shell=False, stdout=PIPE, stderr=STDOUT)
return p
def pipe(a, b, indent=True):
"""Pipes stream A to stream B, with optional indentation."""
for line in a:
for line in iter(a.readline, b''):
if indent:
b.write(' ')