2018-02-02 15:47:17 +01:00
|
|
|
# Copyright (C) 2018 SUSE Linux. All rights reserved.
|
|
|
|
# This program is free software; it may be used, copied, modified
|
|
|
|
# and distributed under the terms of the GNU General Public Licence,
|
|
|
|
# either version 2, or (at your option) any later version.
|
2006-07-14 19:39:46 +02:00
|
|
|
|
2018-02-02 15:47:17 +01:00
|
|
|
import progressbar as pb
|
2006-07-14 19:39:46 +02:00
|
|
|
|
|
|
|
|
2018-02-02 15:47:17 +01:00
|
|
|
class TextMeter(object):
|
2009-10-20 16:30:15 +02:00
|
|
|
|
2018-02-02 15:47:17 +01:00
|
|
|
def start(self, basename, size=None):
|
|
|
|
if size is None:
|
|
|
|
widgets = [basename + ': ', pb.AnimatedMarker(), ' ', pb.Timer()]
|
|
|
|
self.bar = pb.ProgressBar(widgets=widgets, maxval=pb.UnknownLength)
|
2006-07-14 19:39:46 +02:00
|
|
|
else:
|
2018-02-02 15:47:17 +01:00
|
|
|
widgets = [basename + ': ', pb.Percentage(), pb.Bar(), ' ',
|
|
|
|
pb.ETA()]
|
|
|
|
self.bar = pb.ProgressBar(widgets=widgets, maxval=size)
|
|
|
|
self.bar.start()
|
2006-07-14 19:39:46 +02:00
|
|
|
|
2018-02-02 15:47:17 +01:00
|
|
|
def update(self, amount_read):
|
|
|
|
self.bar.update(amount_read)
|
2006-07-14 19:39:46 +02:00
|
|
|
|
2018-02-02 15:47:17 +01:00
|
|
|
def end(self):
|
|
|
|
self.bar.finish()
|
2010-02-25 09:52:47 +01:00
|
|
|
|
|
|
|
# vim: sw=4 et
|