On 10/03/2012 09:24 PM, andrea wrote:
> On 10/02/2012 09:58 AM, Zdenek Pavlas wrote:
> Hi,
>
> I think I did not explain myself very well.
> I am trying to achieve a single nice progress bar across multiple files.
> I know there are N files, more or less the same length but I do not know the
> total size when I
> create the progress.
> I attach below my current solution. I wrap a TextMeter inside my object and I
> estimate the size
> each time "start" is called, assuming the remaining sizes are equal to the
> average of the files so
> far. And I always call "update" with the cumulative read from the beginning.
>
> It almost works very well but there are a couple of issues
>
> 1) each time I call start, BaseMeter resets last_amount_read to 0, so I have
> a jump in the rate
> estimation.
> I found a simple solution to add an extra parameter to "start" last_read=0,
> which I can use as it is
> like I start to download a file, not from the begin. So I pass the total
> amount read so far.
Hi, I know what I want, but I can obtain it directly since in python nothing is
private:
Basically I call progress.start and the begin, and each time my .start() gets
called, I simply have
to tell the TextMeter to update its total size.
I could add a method to do it, but easy enough to cheat and force it:
if self.filesSoFar == 1:
urlgrabber.progress.TextMeter.start(self, filename, url, basename,
estimatedTotal,
self.now, self.name)
else:
#update total
self.size = estimatedTotal
self.fsize = urlgrabber.progress.format_number(estimatedTotal) + 'B'
self.re.total = estimatedTotal
The else clause could be nicely hidden in a new method of TextMeter, but it
works well anyway.
So for the underlying TextMeter there is only 1 file, even though its total
size is adjusted while
we go along.
That could make a nice "ConcatMeter" if you are interested.
Andrea
_______________________________________________
Yum-devel mailing list
[email protected]
http://lists.baseurl.org/mailman/listinfo/yum-devel