~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/progress.py

  • Committer: Vincent Ladeuil
  • Date: 2008-01-03 08:49:38 UTC
  • mfrom: (3111.1.31 175524)
  • mto: This revision was merged to the branch mainline in revision 3158.
  • Revision ID: v.ladeuil+lp@free.fr-20080103084938-7kvurk5uvde2ui54
Fix bug #175524, http test servers are 1.1 compliant

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
 
51
51
 
52
52
def _supports_progress(f):
 
53
    """Detect if we can use pretty progress bars on the output stream f.
 
54
 
 
55
    If this returns true we expect that a human may be looking at that 
 
56
    output, and that we can repaint a line to update it.
 
57
    """
53
58
    isatty = getattr(f, 'isatty', None)
54
59
    if isatty is None:
55
60
        return False
74
79
        if _supports_progress(to_file):
75
80
            return TTYProgressBar(to_file=to_file, **kwargs)
76
81
        else:
77
 
            return DotsProgressBar(to_file=to_file, **kwargs)
 
82
            return DummyProgress(to_file=to_file, **kwargs)
78
83
    else:
79
84
        # Minor sanitation to prevent spurious errors
80
85
        requested_bar_type = requested_bar_type.lower().strip()
456
461
 
457
462
    def update(self, msg, current_cnt=None, total_cnt=None):
458
463
        self.current = current_cnt
459
 
        self.total = total_cnt
 
464
        if total_cnt is not None:
 
465
            self.total = total_cnt
460
466
        self.message = msg
461
467
        self.child_fraction = 0
462
468
        self.tick()
543
549
            self.cur_phase = 0
544
550
        else:
545
551
            self.cur_phase += 1
546
 
        assert self.cur_phase < self.total 
 
552
        assert self.cur_phase < self.total
547
553
        self.pb.update(self.message, self.cur_phase, self.total)
548
554
 
549
555