From 4e0d9507763c543fd8f4a868be36f6cff1a8108c Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Feb 17 2017 05:20:48 +0000 Subject: [cli] use 'avg' api from python-progress This has been fixed in f24+ and epel7 (rhbz#1299634). The benefit of official API is that it implements "moving average" speed measurement (the real speed for latest several seconds), instead of average download speed for the whole download time. This reverts commit fc498e28d1c87d304d0e2c75798ca502e066f0a8. --- diff --git a/cli/copr_cli/util.py b/cli/copr_cli/util.py index 0653f81..1887aca 100644 --- a/cli/copr_cli/util.py +++ b/cli/copr_cli/util.py @@ -1,7 +1,5 @@ # coding: utf-8 -from datetime import timedelta - try: from progress.bar import Bar except ImportError: @@ -25,13 +23,9 @@ class ProgressMixin(object): @property def download_speed(self): - if self.elapsed == 0: - return "0MB/s" - return format_size(self.index/self.elapsed) + "/s" - - @property - def myeta_td(self): - return timedelta(seconds=int(self.remaining*self.elapsed/self.index)) + if self.avg == 0.0: + return "..." + return format_size(1 / self.avg) + "/s" @property def downloaded(self): @@ -53,7 +47,6 @@ class DummyBar(object): if progress: class ProgressBar(Bar, ProgressMixin): message = "%(percent)d%%" - suffix = "%(downloaded)s %(download_speed)s eta %(myeta_td)s" - + suffix = "%(downloaded)s %(download_speed)s eta %(eta_td)s" else: ProgressBar = DummyBar