Show More
@@ -228,6 +228,17 b' class progbar(object):' | |||||
228 | return _('%d %s/sec') % (delta / elapsed, unit) |
|
228 | return _('%d %s/sec') % (delta / elapsed, unit) | |
229 | return '' |
|
229 | return '' | |
230 |
|
230 | |||
|
231 | def _oktoprint(self, now): | |||
|
232 | '''Check if conditions are met to print - e.g. changedelay elapsed''' | |||
|
233 | if (self.lasttopic is None # first time we printed | |||
|
234 | # not a topic change | |||
|
235 | or self.curtopic == self.lasttopic | |||
|
236 | # it's been long enough we should print anyway | |||
|
237 | or now - self.lastprint >= self.changedelay): | |||
|
238 | return True | |||
|
239 | else: | |||
|
240 | return False | |||
|
241 | ||||
231 | def progress(self, topic, pos, item='', unit='', total=None): |
|
242 | def progress(self, topic, pos, item='', unit='', total=None): | |
232 | now = time.time() |
|
243 | now = time.time() | |
233 | try: |
|
244 | try: | |
@@ -258,11 +269,7 b' class progbar(object):' | |||||
258 | self.topicstates[topic] = pos, item, unit, total |
|
269 | self.topicstates[topic] = pos, item, unit, total | |
259 | self.curtopic = topic |
|
270 | self.curtopic = topic | |
260 | if now - self.lastprint >= self.refresh and self.topics: |
|
271 | if now - self.lastprint >= self.refresh and self.topics: | |
261 |
if |
|
272 | if self._oktoprint(now): | |
262 | # not a topic change |
|
|||
263 | or topic == self.lasttopic |
|
|||
264 | # it's been long enough we should print anyway |
|
|||
265 | or now - self.lastprint >= self.changedelay): |
|
|||
266 | self.lastprint = now |
|
273 | self.lastprint = now | |
267 | self.show(now, topic, *self.topicstates[topic]) |
|
274 | self.show(now, topic, *self.topicstates[topic]) | |
268 | finally: |
|
275 | finally: |
General Comments 0
You need to be logged in to leave comments.
Login now