summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Dolbec <brian.dolbec@gmail.com>2011-03-27 19:50:10 -0700
committerBrian Dolbec <brian.dolbec@gmail.com>2011-03-27 19:50:10 -0700
commit58530ac4e610f8eb9952ba8ee7ca920d400915db (patch)
tree977bfa5eafef6ba4f8ce54d1b332c3ef7b6c02b5
parenteab52f261bda8aef53675271357b3ca742f865ad (diff)
downloadlayman-58530ac4e610f8eb9952ba8ee7ca920d400915db.tar.gz
layman-58530ac4e610f8eb9952ba8ee7ca920d400915db.tar.bz2
layman-58530ac4e610f8eb9952ba8ee7ca920d400915db.zip
fix double output for info sent to output.error() due to callback.
-rw-r--r--layman/cli.py5
-rw-r--r--layman/output.py7
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)