Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdout buffer flushes in realtime; closes #49 #50

Merged
merged 1 commit into from
Sep 26, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion bin/brew-file
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,18 @@ class BrewHelper:
def __init__(self, opt):
self.opt = opt

@staticmethod
def readstdout(proc):
while True:
line = proc.stdout.readline()
code = proc.poll()
if line == '':
if code is not None:
break
else:
continue
yield line

def proc(self, cmd, print_cmd=True, print_out=True,
exit_on_error=True, separete_err_msg=False, verbose_level=1):
""" Get process output."""
Expand All @@ -158,7 +170,7 @@ class BrewHelper:
try:
stderr = None if separete_err_msg else subprocess.STDOUT
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=stderr)
for line in p.stdout:
for line in self.readstdout(p):
l = my_decode(line).rstrip()
lines.append(l)
if print_out:
Expand Down