[Zope-Checkins]
SVN: Zope/trunk/lib/python/Products/ZCatalog/ProgressHandler.py
added calculation of estimated termination
Andreas Jung
andreas at andreas-jung.com
Mon Jul 19 07:39:19 EDT 2004
Log message for revision 26620:
added calculation of estimated termination
Changed:
U Zope/trunk/lib/python/Products/ZCatalog/ProgressHandler.py
-=-
Modified: Zope/trunk/lib/python/Products/ZCatalog/ProgressHandler.py
===================================================================
--- Zope/trunk/lib/python/Products/ZCatalog/ProgressHandler.py 2004-07-19 04:19:07 UTC (rev 26619)
+++ Zope/trunk/lib/python/Products/ZCatalog/ProgressHandler.py 2004-07-19 11:39:19 UTC (rev 26620)
@@ -18,8 +18,11 @@
import time, sys
from zLOG import LOG, INFO
+from DateTime.DateTime import DateTime
+
from Interface import Interface
+
class IProgressHandler(Interface):
""" A handler to log progress informations for long running
operations.
@@ -72,9 +75,13 @@
(time.time() -self._start))
def report(self, current, *args, **kw):
- if current % self._steps == 0:
- self.output('%d/%d (%.2f%%)' % (current, self._max,
- (100.0 * current / self._max)))
+ if current > 0:
+ seconds_so_far = time.time() - self._start
+ seconds_to_go = seconds_so_far / current * (self._max - current)
+ if current % self._steps == 0:
+ self.output('%d/%d (%.2f%%) Estimated termination: %s' % \
+ (current, self._max, (100.0 * current / self._max),
+ DateTime(time.time() + seconds_to_go)))
def output(self, text):
print >>self.fp, '%s: %s' % (self._ident, text)
More information about the Zope-Checkins
mailing list