[PATCH 1 of 2] Add a progress indicator

Martin Geisler mg at daimi.au.dk
Sat Dec 13 14:53:21 CST 2008


--=-=-=
Content-Transfer-Encoding: quoted-printable

"Stefano Tortarolo" <stefano.tortarolo at gmail.com> writes:

> 2008/12/12 Martin Geisler <mg at daimi.au.dk>:
>> Are you are aware that there is already a very nice progress bar library
>> for Python?
>>
>>  http://pypi.python.org/pypi/progressbar
>
>
> Yes, I'm aware of that code since it already appeared on this list
> more than 1 year ago [1].

Ah, right :-) I was just afraid that you were reinventing the wheel.

> By the way, It seems a bit overkill to me, I'd rather have a less
> featured yet well integrated progress indicator.
> My major concern about that code is that we still need to add an
> activation threshold.

I just tried with this code and it seems to do the job:

From=20progressbar import ProgressBar
import time, random

class DelayedBar(ProgressBar):

    def __init__(self, **kwargs):
        self.threshold =3D kwargs.pop('threshold', 0)
        ProgressBar.__init__(self, **kwargs)

    def update(self, value):
        if not self.start_time:
            self.start_time =3D time.time()
        if time.time() - self.start_time > self.threshold:
            ProgressBar.update(self, value)

pbar =3D DelayedBar(threshold=3D5)

for i in range(100):
    pbar.update(i)
    time.sleep(0.5 * random.random())

> It would be great to know what was wrong in [1].

Yeah, that puzzles me too...

> Cheers,
> Stefano
>
> [1] http://thread.gmane.org/gmane.comp.version-control.mercurial.devel/12=
621

=2D-=20
Martin Geisler

VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multiparty Computation) to Python. See: http://viff.dk/.

--=-=-=
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAklEIMEACgkQ6nfwy35F3TjhRwCgsv7ZZVg+MCkStMVVR5OTCStW
uIkAoPHXePXoR+FuW+0LH5cYVemCKj0K
=8C3z
-----END PGP SIGNATURE-----
--=-=-=--


More information about the Mercurial-devel mailing list