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
79d3b778
Commit
79d3b778
authored
Jul 15, 2004
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added interface
parent
d532b3b6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
2 deletions
+34
-2
lib/python/Products/ZCatalog/ProgressHandler.py
lib/python/Products/ZCatalog/ProgressHandler.py
+34
-2
No files found.
lib/python/Products/ZCatalog/ProgressHandler.py
View file @
79d3b778
...
...
@@ -18,9 +18,39 @@ $Id: ZCatalog.py 25050 2004-05-27 15:06:40Z chrisw $
import
time
,
sys
from
zLOG
import
LOG
,
INFO
from
Interface
import
Interface
class
IProgressHandler
(
Interface
):
""" A handler to log progress informations for long running
operations.
"""
def
init
(
ident
,
max
):
""" Called add the start of the long running process.
'ident' -- a string identifying the operation
'max' -- maximum number of objects to be processed
"""
def
finish
():
""" Called up terminiation """
def
report
(
current
,
*
args
,
**
kw
):
""" Called for every iteration.
'current' -- an integer representing the number of objects
processed so far.
"""
def
output
(
text
):
""" Log 'text' to some output channel """
class
StdoutHandler
:
""" A simple progress handler """
__implements__
=
IProgressHandler
def
__init__
(
self
,
steps
=
100
):
self
.
_steps
=
steps
...
...
@@ -29,10 +59,10 @@ class StdoutHandler:
self
.
_max
=
max
self
.
_start
=
time
.
time
()
self
.
fp
=
sys
.
stdout
self
.
output
(
'started'
)
self
.
output
(
'
Process
started'
)
def
finish
(
self
):
self
.
output
(
'terminated. Duration: %0.2f seconds'
%
\
self
.
output
(
'
Process
terminated. Duration: %0.2f seconds'
%
\
(
time
.
time
()
-
self
.
_start
))
def
report
(
self
,
current
,
*
args
,
**
kw
):
...
...
@@ -46,6 +76,8 @@ class StdoutHandler:
class
ZLogHandler
(
StdoutHandler
):
""" Use zLOG """
__implements__
=
IProgressHandler
def
output
(
self
,
text
):
LOG
(
self
.
_ident
,
INFO
,
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