~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/text.py

  • Committer: Martin Pool
  • Date: 2008-12-15 06:31:20 UTC
  • mto: (3882.7.11 progress)
  • mto: This revision was merged to the branch mainline in revision 3940.
  • Revision ID: mbp@sourcefrog.net-20081215063120-s06lzbt1fye3lbim
Preliminary support for drawing network io into the progress bar

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
                         select.
50
50
        """
51
51
        super(TextUIFactory, self).__init__()
52
 
        # XXX: mbp, temporarily disabled so we can see the network progress
53
 
        self._bar_type = progress.DummyProgress # bar_type
 
52
        self._bar_type = bar_type
54
53
        if stdout is None:
55
54
            self.stdout = sys.stdout
56
55
        else:
63
62
        self._total_byte_count = 0
64
63
        self._bytes_since_update = 0
65
64
        self._last_activity_time = None
 
65
        # there must always be a top-level progress bar, even if it's not
 
66
        # always shown.
 
67
        self.nested_progress_bar()
66
68
 
67
69
    def prompt(self, prompt):
68
70
        """Emit prompt on the CLI."""
84
86
 
85
87
        This will, clear any progress bars, and leave the cursor at the
86
88
        leftmost position."""
 
89
        # XXX: If this is preparing to write to stdout, but that's for example
 
90
        # directed into a file rather than to the terminal, and the progress
 
91
        # bar _is_ going to the terminal, we shouldn't need
 
92
        # to clear it.  We might need to separately check for the case of 
87
93
        if self._progress_bar_stack is None:
88
94
            return
89
95
        overall_pb = self._progress_bar_stack.bottom()
107
113
            # guard against clock stepping backwards, and don't update too
108
114
            # often
109
115
            rate = self._bytes_since_update / (now - self._last_activity_time)
110
 
            sys.stderr.write("transport %6dkB @ %6.1fkB/s                            \r" %
 
116
            msg = ("%6dkB @ %6.1fkB/s" %
111
117
                (self._total_byte_count>>10, int(rate)>>10,))
112
118
            self._last_activity_time = now
113
119
            self._bytes_since_update = 0
 
120
            overall_pb = self._progress_bar_stack.bottom()
 
121
            overall_pb.update(msg=None, transport_msg=msg)