def test_get_eta(self): bar = ProgressBar(100) bar.stream = StringIO() bar.render(50) now = datetime.datetime.now() delta = now - bar.started self.assertEquals(get_total_seconds(bar.get_eta(now)), int(get_total_seconds(delta) * 0.5)) bar.render(75) now = datetime.datetime.now() delta = now - bar.started self.assertEquals(get_total_seconds(bar.get_eta(now)), int(get_total_seconds(delta) * 0.25))
def get_eta(self, current_time=None): if current_time is None: current_time = datetime.datetime.now() if self.step == 0: return datetime.timedelta() total_seconds = get_total_seconds(self.get_total_time()) eta_seconds = total_seconds * self.steps / self.step - total_seconds return datetime.timedelta(seconds=int(eta_seconds))
def get_rendered_speed(self, step=None, total_seconds=None): if step is None: step = self.step if total_seconds is None: total_seconds = get_total_seconds(self.get_total_time()) if step <= 0 or total_seconds <= 0: speed = "-" else: speed = filesizeformat(float(step) / total_seconds) return "%s: %s/s" % (self.speed_label, speed)
def get_rendered_speed(self, step=None, total_seconds=None): if step is None: step = self.step if total_seconds is None: total_seconds = get_total_seconds(self.get_total_time()) if step <= 0 or total_seconds <= 0: speed = '-' else: speed = filesizeformat(float(step) / total_seconds) return '%s: %s/s' % (self.speed_label, speed)
def assertTotalSecondsEqual(self, timedelta, expected_seconds): result = get_total_seconds(timedelta) self.assertEqual( result, expected_seconds, "We computed %s seconds for %s but expected %s" % (result, timedelta, expected_seconds))
def assertTotalSecondsEqual(self, timedelta, expected_seconds): result = get_total_seconds(timedelta) self.assertEqual(result, expected_seconds, "We computed %s seconds for %s but expected %s" % (result, timedelta, expected_seconds))