1
# Copyright (C) 2005-2010 Canonical Ltd
1
# Copyright (C) 2005, 2008, 2009, 2010 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
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
68
64
def be_quiet(self, state):
69
65
if state and not self._quiet:
242
238
warnings.warn("%r updated but no tasks are active" %
244
240
elif task != self._task_stack[-1]:
245
# We used to check it was the top task, but it's hard to always
246
# get this right and it's not necessarily useful: any actual
247
# problems will be evident in use
248
#warnings.warn("%r is not the top progress task %r" %
249
# (task, self._task_stack[-1]))
241
warnings.warn("%r is not the top progress task %r" %
242
(task, self._task_stack[-1]))
251
243
self._progress_view.show_progress(task)
253
245
def _progress_all_finished(self):
254
246
self._progress_view.clear()
256
def show_user_warning(self, warning_id, **message_args):
257
"""Show a text message to the user.
259
Explicitly not for warnings about bzr apis, deprecations or internals.
261
# eventually trace.warning should migrate here, to avoid logging and
262
# be easier to test; that has a lot of test fallout so for now just
263
# new code can call this
264
if warning_id not in self.suppressed_warnings:
265
self.stderr.write(self.format_user_warning(warning_id, message_args) +
269
249
class TextProgressView(object):
270
250
"""Display of progress bar and other information on a tty.