Skip to content
This repository has been archived by the owner on Sep 24, 2021. It is now read-only.

Commit

Permalink
flush output in pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
wlxiong committed Aug 14, 2014
1 parent c605194 commit 68dde0b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions lixian_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __enter__(self):
softspace = get_softspace(sys.stdout)
sys.stdout = console
sys.stdout.softspace = softspace
return console
def __exit__(self, type, value, traceback):
softspace = get_softspace(sys.stdout)
sys.stdout = self.stdout
Expand Down
9 changes: 7 additions & 2 deletions lixian_colors_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,10 @@ def write(self, s):
else:
raise
def flush(self, *args):
self.output.flush(*args)

try:
self.output.flush(*args)
except IOError as e:
if e.errno == errno.EPIPE:
sys.exit(141)
else:
raise
3 changes: 2 additions & 1 deletion lixian_commands/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def output_tasks(tasks, columns, args, top=True):
'failed':'red',
}
c = status_colors[t['status_text']]
with colors(args.colors).ansi(c)():
with colors(args.colors).ansi(c)() as output:
for k in columns:
if k == 'n':
if top:
Expand Down Expand Up @@ -103,6 +103,7 @@ def output_tasks(tasks, columns, args, top=True):
else:
raise NotImplementedError(k)
print
output.flush()

def usage(doc=lixian_help.usage, message=None):
if hasattr(doc, '__call__'):
Expand Down

0 comments on commit 68dde0b

Please sign in to comment.