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

direct stderr output to stderr again #424

Merged
merged 3 commits into from
Jan 13, 2017
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
25 changes: 19 additions & 6 deletions catkin_tools/execution/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,10 +626,14 @@ def run(self):
del active_stages[event.data['job_id']]

header_border = None
header_border_file = sys.stdout
header_title = None
header_title_file = sys.stdout
lines = []
footer_title = None
footer_title_file = sys.stdout
footer_border = None
footer_border_file = sys.stdout

# Generate headers / borders for output
if event.data['succeeded']:
Expand All @@ -645,12 +649,15 @@ def run(self):

# Output contains warnings
header_border = clr('@!@{yf}' + '_' * (terminal_width() - 1) + '@|')
header_border_file = sys.stderr
header_title = clr(
'Warnings << {}:{} {}').format(
event.data['job_id'],
event.data['stage_label'],
event.data['logfile_filename'])
header_title_file = sys.stderr
footer_border = clr('@{yf}' + '.' * (terminal_width() - 1) + '@|')
footer_border_file = sys.stderr
else:
# Normal output, no warnings
header_title = clr(
Expand All @@ -665,20 +672,25 @@ def run(self):
else:
# Output contains errors
header_border = clr('@!@{rf}' + '_' * (terminal_width() - 1) + '@|')
header_border_file = sys.stderr
header_title = clr(
'Errors << {}:{} {}').format(
event.data['job_id'],
event.data['stage_label'],
event.data['logfile_filename'])
header_title_file = sys.stderr
footer_border = clr('@{rf}' + '.' * (terminal_width() - 1) + '@|')
footer_border_file = sys.stderr

footer_title = clr(
'Failed << {}:{:<{}} [ Exited with code {} ]').format(
event.data['job_id'],
event.data['stage_label'],
max(0, self.max_jid_length - len(event.data['job_id'])),
event.data['retcode'])
footer_title_file = sys.stderr

lines_target = sys.stdout
if self.show_buffered_stdout:
if len(event.data['interleaved']) > 0:
lines = [
Expand All @@ -697,6 +709,7 @@ def run(self):
for l in event.data['stderr'].splitlines(True)
if (self.show_compact_io is False or len(l.strip()) > 0)
]
lines_target = sys.stderr
else:
header_border = None
header_title = None
Expand All @@ -709,19 +722,19 @@ def run(self):

# Print the output
if header_border:
wide_log(header_border)
wide_log(header_border, file=header_border_file)
if header_title:
wide_log(header_title)
wide_log(header_title, file=header_title_file)
if len(lines) > 0:
wide_log(''.join(lines), end='\r')
wide_log(''.join(lines), end='\r', file=lines_target)
if footer_border:
wide_log(footer_border)
wide_log(footer_border, file=footer_border_file)
if footer_title:
wide_log(footer_title)
wide_log(footer_title, file=footer_title_file)

elif 'STDERR' == eid:
if self.show_live_stderr and len(event.data['data']) > 0:
wide_log(self.format_interleaved_lines(event.data), end='\r')
wide_log(self.format_interleaved_lines(event.data), end='\r', file=sys.stderr)

elif 'STDOUT' == eid:
if self.show_live_stdout and len(event.data['data']) > 0:
Expand Down