Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
3641553d
Commit
3641553d
authored
Aug 01, 2010
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PEP8
parent
b62b846e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
+13
-9
src/Products/ZCatalog/ProgressHandler.py
src/Products/ZCatalog/ProgressHandler.py
+13
-9
No files found.
src/Products/ZCatalog/ProgressHandler.py
View file @
3641553d
...
...
@@ -11,7 +11,8 @@
#
##############################################################################
import
time
,
sys
import
sys
import
time
from
logging
import
getLogger
from
DateTime.DateTime
import
DateTime
...
...
@@ -20,8 +21,9 @@ from zope.interface import implements
LOG
=
getLogger
(
'ProgressHandler'
)
class
IProgressHandler
(
Interface
):
""" A handler to log progress informations for long running
""" A handler to log progress informations for long running
operations.
"""
...
...
@@ -30,7 +32,7 @@ class IProgressHandler(Interface):
'ident' -- a string identifying the operation
'max' -- maximum number of objects to be processed (int)
"""
"""
def
info
(
text
):
""" Log some 'text'"""
...
...
@@ -41,12 +43,12 @@ class IProgressHandler(Interface):
def
report
(
current
,
*
args
,
**
kw
):
""" Called for every iteration.
'current' -- an integer representing the number of objects
'current' -- an integer representing the number of objects
processed so far.
"""
def
output
(
text
):
""" Log 'text' to some output channel """
""" Log 'text' to some output channel """
class
StdoutHandler
:
...
...
@@ -73,12 +75,14 @@ class StdoutHandler:
def
report
(
self
,
current
,
*
args
,
**
kw
):
if
current
>
0
:
if
current
%
self
.
_steps
==
0
:
if
current
%
self
.
_steps
==
0
:
seconds_so_far
=
time
.
time
()
-
self
.
_start
seconds_to_go
=
seconds_so_far
/
current
*
(
self
.
_max
-
current
)
seconds_to_go
=
(
seconds_so_far
/
current
*
(
self
.
_max
-
current
))
end
=
DateTime
(
time
.
time
()
+
seconds_to_go
)
self
.
output
(
'%d/%d (%.2f%%) Estimated termination: %s'
%
\
(
current
,
self
.
_max
,
(
100.0
*
current
/
self
.
_max
),
DateTime
(
time
.
time
()
+
seconds_to_go
)
.
strftime
(
'%Y/%m/%d %H:%M:%Sh'
)))
(
current
,
self
.
_max
,
(
100.0
*
current
/
self
.
_max
),
end
.
strftime
(
'%Y/%m/%d %H:%M:%Sh'
)))
def
output
(
self
,
text
):
print
>>
self
.
fp
,
'%s: %s'
%
(
self
.
_ident
,
text
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment