Gentoo Archives: gentoo-commits

From: Brian Dolbec <brian.dolbec@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/layman:master commit in: layman/
Date: Wed, 27 Apr 2011 10:59:28
Message-Id: 58530ac4e610f8eb9952ba8ee7ca920d400915db.dol-sen@gentoo
1 commit: 58530ac4e610f8eb9952ba8ee7ca920d400915db
2 Author: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
3 AuthorDate: Mon Mar 28 02:50:10 2011 +0000
4 Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
5 CommitDate: Mon Mar 28 02:50:10 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=58530ac4
7
8 fix double output for info sent to output.error() due to callback.
9
10 ---
11 layman/cli.py | 5 +++--
12 layman/output.py | 7 ++++---
13 2 files changed, 7 insertions(+), 5 deletions(-)
14
15 diff --git a/layman/cli.py b/layman/cli.py
16 index d58c4ff..c8093c3 100644
17 --- a/layman/cli.py
18 +++ b/layman/cli.py
19 @@ -96,9 +96,12 @@ class ListPrinter(object):
20 elif complain:
21 # Give a reason why this is marked red if it is a verbose
22 # listing
23 + prev_state = self.output.block_callback
24 + self.output.block_callback = True
25 if self.config['verbose']:
26 self.output.error(NOT_SUPPORTED_MSG)
27 self.output.error(summary)
28 + self.output.block_callback = prev_state
29
30
31 def short_list(self, overlay):
32 @@ -262,9 +265,7 @@ class Main(object):
33
34 info = self.api.get_info_str(selection, local=False,
35 verbose=True, width=list_printer.width)
36 - #print("info =", info)
37 list_printer.print_shortdict(info, complain=_complain)
38 -
39 return info != {}
40
41
42
43 diff --git a/layman/output.py b/layman/output.py
44 index caccd93..06161ca 100644
45 --- a/layman/output.py
46 +++ b/layman/output.py
47 @@ -49,6 +49,7 @@ class MessageBase(object):
48 # callback function that gets passed any error messages
49 # that have shown up.
50 self.error_callback = error_callback
51 + self.block_callback = False
52
53
54 def _color (self, col, text):
55 @@ -81,7 +82,7 @@ class MessageBase(object):
56 """runs the error_callback function with the error
57 that occurred
58 """
59 - if self.error_callback:
60 + if self.error_callback is not None and not self.block_callback:
61 self.error_callback(error)
62
63
64 @@ -135,7 +136,7 @@ class Message(MessageBase):
65
66 lines = message.split('\n')
67
68 - if not lines:
69 + if not len(lines):
70 return
71
72 for i in lines[0:-1]:
73 @@ -179,7 +180,7 @@ class Message(MessageBase):
74 # stay in nice order. This is a workaround for calls like
75 # "layman -L |& less".
76 sys.stdout.flush()
77 - print(self.color_func('red', '* ') + i, file=self.error_out)
78 + print(self.color_func('red', '* ') + i, file=self.std_out)
79 self.error_out.flush()
80 self.do_error_callback(error)