def update_progress(self): if not self.pbar: return # progress bar not enabled if not self.hgthread.isAlive(): self.pbar.unmap() else: # pulse the progress bar every ~100ms tm = shlib.get_system_times()[4] if tm - self.last_pbar_update < 0.100: return self.last_pbar_update = tm self.pbar.pulse()
def update_progress(self): if not self.pbar: return if not self.hgthread.isAlive(): self.clear_progress() return data = None while self.hgthread.getprogqueue().qsize(): try: data = self.hgthread.getprogqueue().get_nowait() except Queue.Empty: pass counting = False if data: topic, item, pos, total, unit = data if pos is None: self.clear_progress() return if total is None: count = '%d' % pos counting = True else: self.pbar.set_fraction(float(pos) / float(total)) count = '%d / %d' % (pos, total) if unit: count += ' ' + unit self.pbar.set_text(count) if item: status = '%s: %s' % (topic, item) else: status = _('Status: %s') % topic self.progstat.set_text(status) if self.progstat.get_property('visible') is False: self.progstat.show() self.inprogress = True if not self.inprogress or counting: # pulse the progress bar every ~100ms tm = shlib.get_system_times()[4] if tm - self.last_pbar_update < 0.100: return self.last_pbar_update = tm self.pbar.pulse()