From 58530ac4e610f8eb9952ba8ee7ca920d400915db Mon Sep 17 00:00:00 2001 From: Brian Dolbec Date: Sun, 27 Mar 2011 19:50:10 -0700 Subject: fix double output for info sent to output.error() due to callback. --- layman/cli.py | 5 +++-- layman/output.py | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/layman/cli.py b/layman/cli.py index d58c4ff..c8093c3 100644 --- a/layman/cli.py +++ b/layman/cli.py @@ -96,9 +96,12 @@ class ListPrinter(object): elif complain: # Give a reason why this is marked red if it is a verbose # listing + prev_state = self.output.block_callback + self.output.block_callback = True if self.config['verbose']: self.output.error(NOT_SUPPORTED_MSG) self.output.error(summary) + self.output.block_callback = prev_state def short_list(self, overlay): @@ -262,9 +265,7 @@ class Main(object): info = self.api.get_info_str(selection, local=False, verbose=True, width=list_printer.width) - #print("info =", info) list_printer.print_shortdict(info, complain=_complain) - return info != {} diff --git a/layman/output.py b/layman/output.py index caccd93..06161ca 100644 --- a/layman/output.py +++ b/layman/output.py @@ -49,6 +49,7 @@ class MessageBase(object): # callback function that gets passed any error messages # that have shown up. self.error_callback = error_callback + self.block_callback = False def _color (self, col, text): @@ -81,7 +82,7 @@ class MessageBase(object): """runs the error_callback function with the error that occurred """ - if self.error_callback: + if self.error_callback is not None and not self.block_callback: self.error_callback(error) @@ -135,7 +136,7 @@ class Message(MessageBase): lines = message.split('\n') - if not lines: + if not len(lines): return for i in lines[0:-1]: @@ -179,7 +180,7 @@ class Message(MessageBase): # stay in nice order. This is a workaround for calls like # "layman -L |& less". sys.stdout.flush() - print(self.color_func('red', '* ') + i, file=self.error_out) + print(self.color_func('red', '* ') + i, file=self.std_out) self.error_out.flush() self.do_error_callback(error) -- cgit v1.2.3-1-g7c22