new upstream release

Version: 1.5-1
This commit is contained in:
Pavel Raiskup 2019-03-18 11:51:35 +01:00
commit e39309c4c3
3 changed files with 54 additions and 16 deletions

View file

@ -22,15 +22,37 @@ compatibility - changes the algorithm so the average speed is
calculation is fast enough, and much more stable (by default it
calculates speed for window of 2 seconds).
We also don't seem to have the monotonic() mess, since we don't seem
to suffer from the same issues.
Fork with this patch backported is maintained in
https://github.com/python-progress/python-progress
diff --git a/MANIFEST.in b/MANIFEST.in
index ef7c4cb..0c73842 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,2 +1 @@
include README.rst LICENSE
-include test_*.py
diff --git a/progress/__init__.py b/progress/__init__.py
index a41f65d..1147462 100644
index e434c25..1cbdce6 100644
--- a/progress/__init__.py
+++ b/progress/__init__.py
@@ -24,16 +24,53 @@ from time import time
__version__ = '1.4'
@@ -18,10 +18,7 @@ from collections import deque
from datetime import timedelta
from math import ceil
from sys import stderr
-try:
- from time import monotonic
-except ImportError:
- from time import time as monotonic
+from time import time
__version__ = '1.5'
@@ -30,19 +27,55 @@ HIDE_CURSOR = '\x1b[?25l'
SHOW_CURSOR = '\x1b[?25h'
+class _Window(object):
@ -76,45 +98,58 @@ index a41f65d..1147462 100644
+ # window structure (in memory), default is unlimited.
+ sma_window_seconds = 2
+ sma_window = None
check_tty = True
hide_cursor = True
def __init__(self, *args, **kwargs):
def __init__(self, message='', **kwargs):
self.index = 0
self.start_ts = time()
- self.start_ts = monotonic()
- self.avg = 0
- self._avg_update_ts = self.start_ts
- self._ts = self.start_ts
- self._xput = deque(maxlen=self.sma_window)
+ self.start_ts = time()
+ self.window = _Window(self.sma_window_seconds, self.sma_window)
for key, val in kwargs.items():
setattr(self, key, val)
@@ -46,15 +83,17 @@ class Infinite(object):
def elapsed(self):
return int(time() - self.start_ts)
@@ -62,23 +95,19 @@ class Infinite(object):
@property
def elapsed(self):
- return int(monotonic() - self.start_ts)
+ return int(time() - self.start_ts)
+
+ @property
+ def avg(self):
+ speed = self.window.avg
+ if speed:
+ return 1/speed
+ return 3600 # better constant?
+
@property
def elapsed_td(self):
return timedelta(seconds=self.elapsed)
- def update_avg(self, n, dt):
- if n > 0:
- xput_len = len(self._xput)
- self._xput.append(dt / n)
- self.avg = sum(self._xput) / len(self._xput)
- now = monotonic()
- # update when we're still filling _xput, then after every second
- if (xput_len < self.sma_window or
- now - self._avg_update_ts > 1):
- self.avg = sum(self._xput) / len(self._xput)
- self._avg_update_ts = now
-
def update(self):
pass
@@ -65,10 +104,7 @@ class Infinite(object):
pass
@@ -112,10 +141,7 @@ class Infinite(object):
return self.file.isatty() if self.check_tty else True
def next(self, n=1):
- now = time()
- now = monotonic()
- dt = now - self._ts
- self.update_avg(n, dt)
- self._ts = now

View file

@ -19,8 +19,8 @@
%global pypi_name progress
Name: python-%{pypi_name}
Version: 1.4
Release: 3%{?dist}
Version: 1.5
Release: 1%{?dist}
Summary: Easy to use progress bars
License: ISC
@ -98,6 +98,9 @@ rm -rf %{pypi_name}.egg-info
%changelog
* Mon Mar 18 2019 Pavel Raiskup <praiskup@redhat.com> - 1.5-1
- the latest upstream release
* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.4-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

View file

@ -1 +1 @@
SHA512 (progress-1.4.tar.gz) = f9973ac4f670632fa4ab27232f53c0c74992329a298f95ea6a39ba7a4cbdccfacd44a49c367bf45d739d4fb652e13c271792eff509c9277e2250c2cdb3e82c48
SHA512 (progress-1.5.tar.gz) = a9bee3498746233f874da2d6509d052882d9592df69c223637279a1fae40174a4dc279b56a7558e95ed173b0d357ae07752501c577a3cb9c79e0f87095838896