1
# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
1
# Copyright (C) 2005, 2006, 2007, 2008, 2009 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
81
81
self._task_stack.append(t)
84
def progress_finished(self, task):
85
if task != self._task_stack[-1]:
86
warnings.warn("%r is not currently active" % (task,))
84
def _progress_finished(self, task):
85
"""Called by the ProgressTask when it finishes"""
86
if not self._task_stack:
87
warnings.warn("%r finished but nothing is active"
89
elif task != self._task_stack[-1]:
90
warnings.warn("%r is not the active task %r"
91
% (task, self._task_stack[-1]))
88
93
del self._task_stack[-1]
94
if not self._task_stack:
95
self._progress_all_finished()
97
def _progress_all_finished(self):
98
"""Called when the top-level progress task finished"""
101
def _progress_updated(self, task):
102
"""Called by the ProgressTask when it changes.
104
Should be specialized to draw the progress.
90
108
def clear_term(self):
91
109
"""Prepare the terminal for output.
93
111
This will, for example, clear text progress bars, and leave the
94
cursor at the leftmost position."""
95
raise NotImplementedError(self.clear_term)
112
cursor at the leftmost position.
97
116
def get_boolean(self, prompt):
98
117
"""Get a boolean question answered from the user.
178
197
"""Write an already-formatted message."""
179
198
self.stdout.write(msg + '\n')
181
def clear_term(self):
184
def show_progress(self, task):
187
def progress_finished(self, task):
191
201
class SilentUIFactory(CLIUIFactory):
192
202
"""A UI Factory which never prints anything.