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
b426828b
Commit
b426828b
authored
Jul 02, 2011
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed a couple of very old scripts written in 2002-2004
parent
aa5c1b27
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
1 addition
and
1890 deletions
+1
-1890
src/Zope2/utilities/README.txt
src/Zope2/utilities/README.txt
+0
-28
src/Zope2/utilities/__init__.py
src/Zope2/utilities/__init__.py
+1
-1
src/Zope2/utilities/check_catalog.py
src/Zope2/utilities/check_catalog.py
+0
-143
src/Zope2/utilities/compilezpy.py
src/Zope2/utilities/compilezpy.py
+0
-68
src/Zope2/utilities/decompilezpy.py
src/Zope2/utilities/decompilezpy.py
+0
-27
src/Zope2/utilities/fixheaders.py
src/Zope2/utilities/fixheaders.py
+0
-26
src/Zope2/utilities/load_site.py
src/Zope2/utilities/load_site.py
+0
-303
src/Zope2/utilities/requestprofiler.py
src/Zope2/utilities/requestprofiler.py
+0
-841
src/Zope2/utilities/tracelog.py
src/Zope2/utilities/tracelog.py
+0
-453
No files found.
src/Zope2/utilities/README.txt
deleted
100644 → 0
View file @
aa5c1b27
This directory contains utility scripts and modules that augment Zope.
To get detailed usage information, run any of these scripts without arguments:
load_site.py -- Load a Zope site from files and directories
This script illustrates used of the Zope RPC mechanism,
ZPublisher.Client. It provides some examples of pitfalls
and their work-arounds.
check_catalog.py -- Perform some consistency tests on a ZCatalog instance
mkzopeinstance.py -- create a Zope instance home
copyzopeskel.py -- copy a Zope instance home skeleton directory to target
mkzeoinstance.py -- create a ZEO instance home
requestprofiler.py -- parse and analyze the Zope "detailed" log file
zpasswd.py -- generate "access" or "inituser" files for use with Zope
compilezpy.py -- compile all .py files to .pyc files in the current
directory and below
decompilezpy.py -- remove all .py[co] files in the current directory
and below
src/Zope2/utilities/__init__.py
View file @
b426828b
#
placeholder
#
\ No newline at end of file
src/Zope2/utilities/check_catalog.py
deleted
100644 → 0
View file @
aa5c1b27
##############################################################################
#
# Copyright (c) 2002 Zope Foundation and Contributors.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""Script to check consistency of a ZCatalog
"""
import
Zope2
import
os
,
sys
,
re
,
getopt
from
types
import
IntType
from
BTrees.IIBTree
import
IISet
,
difference
,
intersection
def
checkCatalog
(
path
,
indexes
):
""" perform some consistency checks on a ZCatalog instance"""
root
=
Zope2
.
app
()
try
:
catalog
=
root
.
unrestrictedTraverse
(
path
)
except
AttributeError
:
print
'Error: catalog object not found'
sys
.
exit
(
1
)
# get Catalog instance
_cat
=
catalog
.
_catalog
# check Catalog internal BTrees
l_data
=
list
(
_cat
.
data
.
keys
())
l_data
.
sort
()
l_uids
=
list
(
_cat
.
uids
.
values
())
l_uids
.
sort
()
l_paths
=
list
(
_cat
.
data
.
keys
())
l_paths
.
sort
()
print
"Checking catalog internal BTrees"
print
"
\
t
INFO: Mapping data: %d entries"
%
len
(
l_data
)
print
"
\
t
INFO: Mapping uids: %d entries"
%
len
(
l_uids
)
print
"
\
t
INFO: Mapping paths: %d entries"
%
len
(
l_paths
)
if
l_data
==
l_uids
:
print
"
\
t
OK: Mapping data equals Mapping uids"
else
:
print
"
\
t
ERR: Mapping data does not equal Mapping uids"
if
l_data
==
l_paths
:
print
"
\
t
OK: Mapping data equals Maaping paths"
else
:
print
"
\
t
ERR: Mapping data does not equal Maaping paths"
# check BTrees of indexes
for
id
,
idx
in
_cat
.
indexes
.
items
():
if
indexes
and
not
idx
.
meta_type
in
indexes
:
continue
print
"Checking index '%s' (type: %s)"
%
(
id
,
idx
.
meta_type
)
if
idx
.
meta_type
in
[
'FieldIndex'
,
'KeywordIndex'
]:
# check forward entries
RIDS
=
IISet
()
for
key
,
rids
in
idx
.
_index
.
items
():
if
isinstance
(
rids
,
IntType
):
RIDS
.
insert
(
rids
)
else
:
map
(
RIDS
.
insert
,
rids
.
keys
())
diff
=
difference
(
RIDS
,
IISet
(
_cat
.
data
.
keys
()))
if
len
(
diff
)
!=
0
:
print
'
\
t
ERR: Problem with forward entries'
print
'
\
t
ERR: too much forward entries:'
,
diff
else
:
print
'
\
t
OK: Forward entries (%d entries)'
%
(
len
(
RIDS
))
elif
idx
.
meta_type
in
[
'PathIndex'
]:
RIDS
=
IISet
()
for
rids
in
map
(
None
,
idx
.
_index
.
values
()):
map
(
RIDS
.
insert
,
rids
.
values
()[
0
])
diff
=
difference
(
RIDS
,
IISet
(
_cat
.
data
.
keys
()))
if
len
(
diff
)
!=
0
:
print
'
\
t
ERR: Problem with forward entries'
print
'
\
t
ERR: too much forward entries:'
,
diff
else
:
print
'
\
t
OK: Forward entries (%d entries)'
%
(
len
(
RIDS
))
if
idx
.
meta_type
in
[
'FieldIndex'
,
'KeywordIndex'
,
'PathIndex'
]:
# check backward entries
RIDS
=
IISet
(
idx
.
_unindex
.
keys
())
diff
=
difference
(
RIDS
,
IISet
(
_cat
.
data
.
keys
()))
if
len
(
diff
)
!=
0
:
print
'
\
t
ERR: Problem with backward entries'
print
'
\
t
ERR: too much backward entries:'
,
diff
else
:
print
'
\
t
OK: Backward entries (%d entries)'
%
(
len
(
RIDS
))
def
usage
():
print
"Usage: %s [--FieldIndex|KeywordIndex|PathIndex] /path/to/ZCatalog"
%
\
os
.
path
.
basename
(
sys
.
argv
[
0
])
print
print
"This scripts checks the consistency of the internal"
print
"BTrees of a ZCatalog and its indexes."
sys
.
exit
(
1
)
def
main
():
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'h'
,
\
[
'help'
,
'FieldIndex'
,
'KeywordIndex'
,
'PathIndex'
])
indexes
=
[]
for
o
,
v
in
opts
:
if
o
in
[
'-h'
,
'--help'
]:
usage
()
if
o
in
[
'--FieldIndex'
,
'--KeywordIndex'
,
'--PathIndex'
]:
indexes
.
append
(
o
[
2
:])
checkCatalog
(
args
,
indexes
)
if
__name__
==
'__main__'
:
main
()
src/Zope2/utilities/compilezpy.py
deleted
100755 → 0
View file @
aa5c1b27
##############################################################################
#
# Copyright (c) 2002 Zope Foundation and Contributors.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
import
compileall
,
os
,
sys
class
Shutup
:
def
write
(
*
args
):
pass
# :)
class
NoteErr
:
wrote
=
0
def
write
(
self
,
*
args
):
self
.
wrote
=
1
apply
(
stderr
.
write
,
args
)
def
compile_non_test
(
dir
):
"""Byte-compile all modules except those in test directories."""
success
=
compileall
.
compile_dir
(
dir
,
maxlevels
=
0
)
try
:
names
=
os
.
listdir
(
dir
)
except
os
.
error
:
print
"Can't list"
,
dir
names
=
[]
names
.
sort
()
for
name
in
names
:
fullname
=
os
.
path
.
join
(
dir
,
name
)
if
(
name
!=
os
.
curdir
and
name
!=
os
.
pardir
and
os
.
path
.
isdir
(
fullname
)
and
not
os
.
path
.
islink
(
fullname
)
and
name
!=
'test'
and
name
!=
'tests'
and
name
!=
'skins'
):
success
=
success
and
compile_non_test
(
fullname
)
return
success
print
print
'-'
*
78
print
'Compiling python modules'
stdout
=
sys
.
stdout
stderr
=
sys
.
stderr
try
:
try
:
success
=
0
sys
.
stdout
=
Shutup
()
sys
.
stderr
=
NoteErr
()
success
=
compile_non_test
(
os
.
getcwd
())
finally
:
success
=
success
and
not
sys
.
stderr
.
wrote
sys
.
stdout
=
stdout
sys
.
stderr
=
stderr
except
:
success
=
0
import
traceback
traceback
.
print_exc
()
if
not
success
:
print
print
'!'
*
78
print
'There were errors during Python module compilation.'
print
'!'
*
78
print
sys
.
exit
(
1
)
src/Zope2/utilities/decompilezpy.py
deleted
100755 → 0
View file @
aa5c1b27
##############################################################################
#
# Copyright (c) 2002 Zope Foundation and Contributors.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
import
os
import
sys
def
main
(
dirname
):
os
.
path
.
walk
(
dirname
,
rmpycs
,
None
)
def
rmpycs
(
arg
,
dirname
,
names
):
for
name
in
names
:
path
=
os
.
path
.
join
(
dirname
,
name
)
if
(
name
.
endswith
(
'.pyc'
)
or
name
.
endswith
(
'.pyo'
)
and
os
.
path
.
isfile
(
path
)
):
os
.
unlink
(
path
)
if
__name__
==
'__main__'
:
main
(
sys
.
argv
[
1
])
src/Zope2/utilities/fixheaders.py
deleted
100644 → 0
View file @
aa5c1b27
# Script to fix the header files to ZPL 2.1
import
os
for
dirpath
,
dirnames
,
filenames
in
os
.
walk
(
'.'
):
for
fname
in
filenames
:
base
,
ext
=
os
.
path
.
splitext
(
fname
)
if
not
ext
in
(
'.py'
,
'.c'
,
'.h'
):
continue
fullname
=
os
.
path
.
join
(
dirpath
,
fname
)
if
'.svn'
in
fullname
:
continue
data
=
open
(
fullname
).
read
()
changed
=
False
if
'Version 2.1 (ZPL)'
in
data
:
data
=
data
.
replace
(
'Version 2.1 (ZPL)'
,
'Version 2.1 (ZPL)'
)
changed
=
True
if
'(c) 2002 Zope Corporation'
in
data
:
data
=
data
.
replace
(
'(c) 2002 Zope Corporation'
,
'(c) 2002 Zope Corporation'
)
changed
=
True
print
fullname
,
changed
if
changed
:
open
(
fullname
,
'w'
).
write
(
data
)
src/Zope2/utilities/load_site.py
deleted
100644 → 0
View file @
aa5c1b27
##############################################################################
#
# Copyright (c) 2002 Zope Foundation and Contributors.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""Load a Zope site from a collection of files or directories
"""
usage
=
""" [options] url file .....
where options are:
-D
For HTML documents, replace the start of the content, up to
and including the opening body tag with a DTML var tag that
inserts the standard header. Also replace the closing body
and html tag with a DTML var tag that inserts the standard
footer.
-I
For each index.html, add an index_html that redirects.
-p path
Path to ZPublisher. If not provided, load_site will
make an attempt to figure it out.
-u user:password
Credentials
-v
Run in verbose mode.
-9
Use *old* zope method names.
"""
import
sys
,
getopt
,
os
,
string
ServerError
=
''
verbose
=
0
old
=
0
doctor
=
0
index_html
=
0
def
main
():
user
,
password
=
'superuser'
,
'123'
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'p:u:DIv9'
)
global
verbose
global
old
global
doctor
global
index_html
havepath
=
None
for
o
,
v
in
opts
:
if
o
==
'-p'
:
d
,
f
=
os
.
path
.
split
(
v
)
if
f
==
'ZPublisher'
:
sys
.
path
.
insert
(
0
,
d
)
else
:
sys
.
path
.
insert
(
0
,
v
)
havepath
=
1
elif
o
==
'-u'
:
v
=
string
.
split
(
v
,
':'
)
user
,
password
=
v
[
0
],
string
.
join
(
v
[
1
:],
':'
)
elif
o
==
'-D'
:
doctor
=
1
elif
o
==
'-I'
:
index_html
=
1
elif
o
==
'-v'
:
verbose
=
1
elif
o
==
'-9'
:
old
=
1
if
not
args
:
print
sys
.
argv
[
0
]
+
usage
sys
.
exit
(
1
)
if
not
havepath
:
here
=
os
.
path
.
split
(
sys
.
argv
[
0
])[
0
]
if
os
.
path
.
exists
(
os
.
path
.
join
(
here
,
'ZPublisher'
)):
sys
.
path
.
insert
(
0
,
here
)
else
:
here
=
os
.
path
.
split
(
here
)[
0
]
here
=
os
.
path
.
join
(
here
,
'lib'
,
'python'
)
if
os
.
path
.
exists
(
os
.
path
.
join
(
here
,
'ZPublisher'
)):
sys
.
path
.
insert
(
0
,
here
)
url
=
args
[
0
]
files
=
args
[
1
:]
import
ZPublisher.Client
global
ServerError
ServerError
=
ZPublisher
.
Client
.
ServerError
object
=
ZPublisher
.
Client
.
Object
(
url
,
username
=
user
,
password
=
password
)
for
f
in
files
:
upload_file
(
object
,
f
)
def
call
(
f
,
*
args
,
**
kw
):
# Call a function ignoring redirect bci errors.
try
:
apply
(
f
,
args
,
kw
)
except
ServerError
,
v
:
if
str
(
v
)[:
1
]
!=
'3'
:
raise
sys
.
exc_info
()[
0
],
sys
.
exc_info
()[
1
],
sys
.
exc_info
()[
2
]
def
upload_file
(
object
,
f
):
if
os
.
path
.
isdir
(
f
):
return
upload_dir
(
object
,
f
)
dir
,
name
=
os
.
path
.
split
(
f
)
root
,
ext
=
os
.
path
.
splitext
(
name
)
if
ext
in
(
'file'
,
'dir'
):
ext
=
''
else
:
ext
=
string
.
lower
(
ext
)
if
ext
and
ext
[
0
]
in
'.'
:
ext
=
ext
[
1
:]
if
ext
and
globals
().
has_key
(
'upload_'
+
ext
):
if
verbose
:
print
'upload_'
+
ext
,
f
return
globals
()[
'upload_'
+
ext
](
object
,
f
)
if
verbose
:
print
'upload_file'
,
f
,
ext
call
(
object
.
manage_addFile
,
id
=
name
,
file
=
open
(
f
,
'rb'
))
def
upload_dir
(
object
,
f
):
if
verbose
:
print
'upload_dir'
,
f
dir
,
name
=
os
.
path
.
split
(
f
)
call
(
object
.
manage_addFolder
,
id
=
name
)
object
=
object
.
__class__
(
object
.
url
+
'/'
+
name
,
username
=
object
.
username
,
password
=
object
.
password
)
for
n
in
os
.
listdir
(
f
):
upload_file
(
object
,
os
.
path
.
join
(
f
,
n
))
# ----- phd -----
# Modified by Oleg Broytmann <phd2@earthling.net>
from
sgmllib
import
SGMLParser
def
join_attrs
(
attrs
):
attr_list
=
[]
for
attrname
,
value
in
attrs
:
attr_list
.
append
(
'%s="%s"'
%
(
attrname
,
string
.
strip
(
value
)))
if
attr_list
:
s
=
" "
+
string
.
join
(
attr_list
,
" "
)
else
:
s
=
""
return
s
class
HeadParser
(
SGMLParser
):
def
__init__
(
self
):
SGMLParser
.
__init__
(
self
)
self
.
seen_starthead
=
0
self
.
seen_endhead
=
0
self
.
seen_startbody
=
0
self
.
head
=
""
self
.
title
=
""
self
.
accumulator
=
""
def
handle_data
(
self
,
data
):
if
data
:
self
.
accumulator
=
self
.
accumulator
+
data
def
handle_charref
(
self
,
ref
):
self
.
handle_data
(
"&#%s;"
%
ref
)
def
handle_entityref
(
self
,
ref
):
self
.
handle_data
(
"&%s;"
%
ref
)
def
handle_comment
(
self
,
data
):
if
data
:
self
.
accumulator
=
self
.
accumulator
+
"<!--%s-->"
%
data
def
start_head
(
self
,
attrs
):
if
not
self
.
seen_starthead
:
self
.
seen_starthead
=
1
self
.
head
=
""
self
.
title
=
""
self
.
accumulator
=
""
def
end_head
(
self
):
if
not
self
.
seen_endhead
:
self
.
seen_endhead
=
1
self
.
head
=
self
.
head
+
self
.
accumulator
self
.
accumulator
=
""
def
start_title
(
self
,
attrs
):
self
.
head
=
self
.
head
+
self
.
accumulator
self
.
accumulator
=
""
def
end_title
(
self
):
self
.
title
=
self
.
accumulator
self
.
accumulator
=
""
def
start_body
(
self
,
attrs
):
if
not
self
.
seen_startbody
:
self
.
seen_startbody
=
1
self
.
accumulator
=
""
def
end_body
(
self
):
pass
# Do not put </BODY> and </HTML>
def
end_html
(
self
):
pass
# into output stream
# Pass other tags unmodified
def
unknown_starttag
(
self
,
tag
,
attrs
):
self
.
accumulator
=
self
.
accumulator
+
"<%s%s>"
%
(
string
.
upper
(
tag
),
join_attrs
(
attrs
))
def
unknown_endtag
(
self
,
tag
):
self
.
accumulator
=
self
.
accumulator
+
"</%s>"
%
string
.
upper
(
tag
)
def
parse_html
(
infile
):
parser
=
HeadParser
()
while
1
:
line
=
infile
.
readline
()
if
not
line
:
break
parser
.
feed
(
line
)
parser
.
close
()
infile
.
close
()
return
(
string
.
strip
(
parser
.
title
),
string
.
strip
(
parser
.
head
),
string
.
strip
(
parser
.
accumulator
))
def
upload_html
(
object
,
f
):
dir
,
name
=
os
.
path
.
split
(
f
)
f
=
open
(
f
)
if
doctor
:
title
,
head
,
body
=
parse_html
(
f
)
if
old
:
body
=
(
"<!--#var standard_html_header-->
\
n
\
n
"
+
body
+
"
\
n
\
n
<!--#var standard_html_footer-->"
)
else
:
body
=
(
"<html><head><title><dtml-var title_or_id></title>"
"</head><body bgcolor=
\
"
#FFFFFF
\
"
>
\
n
\
n
"
+
body
+
"
\
n
\
n
</body></html>"
)
else
:
if
old
:
f
=
f
.
read
()
title
,
head
,
body
=
''
,
''
,
f
if
old
:
call
(
object
.
manage_addDocument
,
id
=
name
,
file
=
body
)
if
index_html
and
name
in
(
'index.html'
,
'index.htm'
):
call
(
object
.
manage_addDocument
,
id
=
'index_html'
,
file
=
(
'<!--#raise Redirect-->'
'<!--#var URL1-->/%s'
'<!--#/raise-->'
%
name
))
else
:
call
(
object
.
manage_addDTMLDocument
,
id
=
name
,
title
=
title
,
file
=
body
)
if
index_html
and
name
in
(
'index.html'
,
'index.htm'
):
call
(
object
.
manage_addDTMLMethod
,
id
=
'index_html'
,
file
=
(
'<dtml-raise Redirect>'
'<dtml-var URL1>/%s'
'</dtml-raise>'
%
name
))
# Now add META and other tags as property
if
head
:
object
=
object
.
__class__
(
object
.
url
+
'/'
+
name
,
username
=
object
.
username
,
password
=
object
.
password
)
call
(
object
.
manage_addProperty
,
id
=
"loadsite-head"
,
type
=
"text"
,
value
=
head
)
# ----- /phd -----
upload_htm
=
upload_html
def
upload_dtml
(
object
,
f
):
dir
,
name
=
os
.
path
.
split
(
f
)
f
=
open
(
f
)
if
old
:
f
=
f
.
read
()
call
(
object
.
manage_addDocument
,
id
=
name
,
file
=
f
)
else
:
call
(
object
.
manage_addDTMLMethod
,
id
=
name
,
file
=
f
)
def
upload_gif
(
object
,
f
):
dir
,
name
=
os
.
path
.
split
(
f
)
call
(
object
.
manage_addImage
,
id
=
name
,
file
=
open
(
f
,
'rb'
))
upload_jpg
=
upload_gif
upload_png
=
upload_gif
if
__name__
==
'__main__'
:
main
()
src/Zope2/utilities/requestprofiler.py
deleted
100644 → 0
View file @
aa5c1b27
This diff is collapsed.
Click to expand it.
src/Zope2/utilities/tracelog.py
deleted
100644 → 0
View file @
aa5c1b27
This diff is collapsed.
Click to expand it.
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