Otherwise, they are suppressed along with the rest of the output. But
if stdout is a terminal, so that output is not suppressed, write
errors through the same Output object as info messages to get the
indentation etc. right.
Signed-off-by: Karl Hasselström <kha@treskal.com>
self.new_line()
self.write(string)
self.at_start_of_line = string.endswith('\n')
self.new_line()
self.write(string)
self.at_start_of_line = string.endswith('\n')
+ self.__stderr = Output(sys.stderr.write, sys.stderr.flush)
self.__stdout = Output(sys.stdout.write, sys.stdout.flush)
if sys.stdout.isatty():
self.__out = self.__stdout
self.__stdout = Output(sys.stdout.write, sys.stdout.flush)
if sys.stdout.isatty():
self.__out = self.__stdout
+ self.__err = self.__stdout
else:
self.__out = Output(lambda msg: None, lambda: None)
else:
self.__out = Output(lambda msg: None, lambda: None)
+ self.__err = self.__stderr
def stdout(self, line):
"""Write a line to stdout."""
self.__stdout.write_line(line)
def stdout_raw(self, string):
"""Write a string possibly containing newlines to stdout."""
self.__stdout.write_raw(string)
def stdout(self, line):
"""Write a line to stdout."""
self.__stdout.write_line(line)
def stdout_raw(self, string):
"""Write a string possibly containing newlines to stdout."""
self.__stdout.write_raw(string)
+ def err_raw(self, string):
+ """Write a string possibly containing newlines to the error
+ output."""
+ self.__err.write_raw(string)
def info(self, *msgs):
for msg in msgs:
self.__out.single_line(msg)
def note(self, *msgs):
self.__out.tagged_lines('Notice', msgs)
def warn(self, *msgs):
def info(self, *msgs):
for msg in msgs:
self.__out.single_line(msg)
def note(self, *msgs):
self.__out.tagged_lines('Notice', msgs)
def warn(self, *msgs):
- self.__out.tagged_lines('Warning', msgs)
+ self.__err.tagged_lines('Warning', msgs)
- self.__out.tagged_lines('Error', msgs)
+ self.__err.tagged_lines('Error', msgs)
def start(self, msg):
"""Start a long-running operation."""
self.__out.single_line('%s ... ' % msg, print_newline = False)
def start(self, msg):
"""Start a long-running operation."""
self.__out.single_line('%s ... ' % msg, print_newline = False)