def __init__(self, start_free, to_write, device): Thread.__init__(self) self.start_free = start_free self.to_write = to_write self.device = device self._stopevent = Event() # TODO evand 2009-07-24: We should fiddle with the min_age and max_age # parameters so this doesn't constantly remind me of the Windows file # copy dialog: http://xkcd.com/612/ self.remtime = RemainingTimeEstimator()
class progress(Thread): def __init__(self, start_free, to_write, device): Thread.__init__(self) self.start_free = start_free self.to_write = to_write self.device = device self._stopevent = Event() # TODO evand 2009-07-24: We should fiddle with the min_age and max_age # parameters so this doesn't constantly remind me of the Windows file # copy dialog: http://xkcd.com/612/ self.remtime = RemainingTimeEstimator() def progress(self, per, remaining, speed): pass def run(self): try: while not self._stopevent.isSet(): free = fs_size(self.device)[1] written = self.start_free - free v = int((written / float(self.to_write)) * 100) est = self.remtime.estimate(written, self.to_write) if callable(self.progress): self.progress(v, est[0], est[1]) self._stopevent.wait(2) except StandardError: logging.exception('Could not update progress:') def join(self, timeout=None): self._stopevent.set() Thread.join(self, timeout)
class progress(Thread): def __init__(self, start_free, to_write, device): Thread.__init__(self) self.start_free = start_free self.to_write = to_write self.device = device self._stopevent = Event() # TODO evand 2009-07-24: We should fiddle with the min_age and max_age # parameters so this doesn't constantly remind me of the Windows file # copy dialog: http://xkcd.com/612/ self.remtime = RemainingTimeEstimator() def progress(self, per, remaining, speed): pass def run(self): try: while not self._stopevent.isSet(): free = fs_size(self.device)[1] written = self.start_free - free v = int((written / float(self.to_write)) * 100) est = self.remtime.estimate(written, self.to_write) if callable(self.progress): self.progress(v, est[0], est[1]) self._stopevent.wait(2) except Exception: logging.exception('Could not update progress:') def join(self, timeout=None): self._stopevent.set() Thread.join(self, timeout)