[Zodb-checkins] CVS: StandaloneZODB/Tools - fstest.py:1.3.6.2
Barry Warsaw
barry@wooz.org
Thu, 10 Jan 2002 13:45:37 -0500
Update of /cvs-repository/StandaloneZODB/Tools
In directory cvs.zope.org:/tmp/cvs-serv6096
Modified Files:
Tag: Standby-branch
fstest.py
Log Message:
Added support for a third -v which increases the verbosity level to
include the md5 checksums of the pickle data. Specifically,
check_drec(): Always read the pickle data and return it, unless of
course plen == 0. In that case, we don't go back to load previous
pickle data because we assume we've already seen it in previous
transactions. So it doesn't matter for diagnostic purposes and we
just return ''.
check_trec(): Ugly hack to print out the checksums when VERBOSE > 2.
Also, I shortened the format string in both chatter() cases so that
with the md5sum, it'll still fit on one line.
=== StandaloneZODB/Tools/fstest.py 1.3.6.1 => 1.3.6.2 ===
If two -v arguments are used, it will also print a line of text for
each object. The objects for a transaction will be printed before the
-transaction itself.
+transaction itself. With three -v arguments, it will also print the md5
+checksums of the pickle data.
Note: It does not check the consistency of the object pickles. It is
possible for the damage to occur only in the part of the file that
@@ -35,6 +36,7 @@
import string
import struct
import sys
+import md5
class FormatError(ValueError):
"""There is a problem with the format of the FileStorage."""
@@ -146,13 +148,20 @@
i = 0
while pos < tend:
_pos = pos
- pos, oid = check_drec(path, file, pos, tpos, tid)
+ pos, oid, data = check_drec(path, file, pos, tpos, tid)
if pos > tend:
raise FormatError("%s has data records that extend beyond"
" the transaction record; end at %s" %
(path, pos))
- chatter("%10d: object oid %s #%d\n" % (_pos, hexify(oid), i),
- level=2)
+ # Blech, ugly hack
+ if VERBOSE > 2:
+ sum = md5.new(data).hexdigest()
+ chatter("%10d: oid %s #%4d : %s\n" %
+ (_pos, hexify(oid), i, sum),
+ level=3)
+ else:
+ chatter("%10d: oid %s #%4d\n" % (_pos, hexify(oid), i),
+ level=2)
i = i + 1
file.seek(tend)
@@ -191,15 +200,23 @@
raise FormatError("%s data record exceeds transaction record"
"at %s" % (path, pos))
- pos = pos + dlen
- # XXX is the following code necessary?
+ # Read the data pickle
if plen:
- file.seek(plen, 1)
+ data = file.read(plen)
else:
+ # Skip over "8-byte position of data record containing data". This
+ # means that the pickle data is actually somewhere else in the file,
+ # which can happen after e.g. non-transactional undo. We don't care
+ # though because some other data record will have already returned
+ # this pickle data, so we can safely ignore it for diagnostic
+ # purposes.
file.seek(8, 1)
+ data = ''
# XXX _loadBack() ?
- return pos, oid
+ # Move the file pointer ahead
+ pos = pos + dlen
+ return pos, oid, data
def usage():
print __doc__
@@ -224,4 +241,4 @@
print msg
sys.exit(-1)
- chatter("no errors detected")
+ chatter("no errors detected\n")