~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/text.py

  • Committer: Alexander Belchenko
  • Date: 2010-06-17 08:53:15 UTC
  • mfrom: (5300 +trunk)
  • mto: (5303.2.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5305.
  • Revision ID: bialix@ukr.net-20100617085315-hr8186zck57zn35s
merge bzr.dev; fix NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
 
38
38
""")
39
39
 
40
 
from bzrlib.osutils import watch_sigwinch
41
 
 
42
40
from bzrlib.ui import (
43
41
    UIFactory,
44
42
    NullProgressView,
62
60
        self.stderr = stderr
63
61
        # paints progress, network activity, etc
64
62
        self._progress_view = self.make_progress_view()
65
 
        # hook up the signals to watch for terminal size changes
66
 
        watch_sigwinch()
67
63
 
68
64
    def be_quiet(self, state):
69
65
        if state and not self._quiet:
157
153
        """Construct and return a new ProgressView subclass for this UI.
158
154
        """
159
155
        # with --quiet, never any progress view
160
 
        # <https://bugs.edge.launchpad.net/bzr/+bug/320035>.  Otherwise if the
 
156
        # <https://bugs.launchpad.net/bzr/+bug/320035>.  Otherwise if the
161
157
        # user specifically requests either text or no progress bars, always
162
158
        # do that.  otherwise, guess based on $TERM and tty presence.
163
159
        if self.is_quiet():
233
229
 
234
230
    def show_warning(self, msg):
235
231
        self.clear_term()
 
232
        if isinstance(msg, unicode):
 
233
            te = osutils.get_terminal_encoding()
 
234
            msg = msg.encode(te, 'replace')
236
235
        self.stderr.write("bzr: warning: %s\n" % msg)
237
236
 
238
237
    def _progress_updated(self, task):
253
252
    def _progress_all_finished(self):
254
253
        self._progress_view.clear()
255
254
 
 
255
    def show_user_warning(self, warning_id, **message_args):
 
256
        """Show a text message to the user.
 
257
 
 
258
        Explicitly not for warnings about bzr apis, deprecations or internals.
 
259
        """
 
260
        # eventually trace.warning should migrate here, to avoid logging and
 
261
        # be easier to test; that has a lot of test fallout so for now just
 
262
        # new code can call this
 
263
        if warning_id not in self.suppressed_warnings:
 
264
            self.stderr.write(self.format_user_warning(warning_id, message_args) +
 
265
                '\n')
 
266
 
256
267
 
257
268
class TextProgressView(object):
258
269
    """Display of progress bar and other information on a tty.