[Zodb-checkins] CVS: ZODB3/ZODB/FileStorage - fsdump.py:1.1.2.2
Jeremy Hylton
jeremy at zope.com
Thu Oct 9 12:10:03 EDT 2003
Update of /cvs-repository/ZODB3/ZODB/FileStorage
In directory cvs.zope.org:/tmp/cvs-serv18130
Modified Files:
Tag: ZODB3-mvcc-2-branch
fsdump.py
Log Message:
Fix a bunch of imports. Simple changes for new struct codes.
=== ZODB3/ZODB/FileStorage/fsdump.py 1.1.2.1 => 1.1.2.2 ===
--- ZODB3/ZODB/FileStorage/fsdump.py:1.1.2.1 Thu Oct 9 11:49:04 2003
+++ ZODB3/ZODB/FileStorage/fsdump.py Thu Oct 9 12:10:01 2003
@@ -1,4 +1,6 @@
from ZODB.FileStorage import FileIterator
+from ZODB.FileStorage.format \
+ import TRANS_HDR, TRANS_HDR_LEN, DATA_HDR, DATA_HDR_LEN
from ZODB.TimeStamp import TimeStamp
from ZODB.utils import u64
from ZODB.tests.StorageTestBase import zodb_unpickle
@@ -6,6 +8,7 @@
from cPickle import Unpickler
from cStringIO import StringIO
import md5
+import struct
import types
def get_pickle_metadata(data):
@@ -77,10 +80,6 @@
i += 1
iter.close()
-import struct
-from ZODB.FileStorage import TRANS_HDR, TRANS_HDR_LEN
-from ZODB.FileStorage import DATA_HDR, DATA_HDR_LEN
-
def fmt(p64):
# Return a nicely formatted string for a packaged 64-bit value
return "%016x" % u64(p64)
@@ -88,6 +87,8 @@
class Dumper:
"""A very verbose dumper for debuggin FileStorage problems."""
+ # XXX Should revise this class to use FileStorageFormatter.
+
def __init__(self, path, dest=None):
self.file = open(path, "rb")
self.dest = dest
@@ -104,13 +105,13 @@
h = self.file.read(TRANS_HDR_LEN)
if not h:
return False
- tid, stlen, status, ul, dl, el = struct.unpack(TRANS_HDR, h)
- end = pos + u64(stlen)
+ tid, tlen, status, ul, dl, el = struct.unpack(TRANS_HDR, h)
+ end = pos + tlen
print >> self.dest, "=" * 60
print >> self.dest, "offset: %d" % pos
print >> self.dest, "end pos: %d" % end
print >> self.dest, "transaction id: %s" % fmt(tid)
- print >> self.dest, "trec len: %d" % u64(stlen)
+ print >> self.dest, "trec len: %d" % tlen
print >> self.dest, "status: %r" % status
user = descr = extra = ""
if ul:
@@ -124,22 +125,21 @@
print >> self.dest, "len(extra): %d" % el
while self.file.tell() < end:
self.dump_data(pos)
- stlen2 = self.file.read(8)
- print >> self.dest, "redundant trec len: %d" % u64(stlen2)
+ stlen = self.file.read(8)
+ print >> self.dest, "redundant trec len: %d" % u64(stlen)
return 1
def dump_data(self, tloc):
pos = self.file.tell()
h = self.file.read(DATA_HDR_LEN)
assert len(h) == DATA_HDR_LEN
- oid, revid, sprev, stloc, vlen, sdlen = struct.unpack(DATA_HDR, h)
- dlen = u64(sdlen)
+ oid, revid, prev, tloc, vlen, dlen = struct.unpack(DATA_HDR, h)
print >> self.dest, "-" * 60
print >> self.dest, "offset: %d" % pos
print >> self.dest, "oid: %s" % fmt(oid)
print >> self.dest, "revid: %s" % fmt(revid)
- print >> self.dest, "previous record offset: %d" % u64(sprev)
- print >> self.dest, "transaction offset: %d" % u64(stloc)
+ print >> self.dest, "previous record offset: %d" % prev
+ print >> self.dest, "transaction offset: %d" % tloc
if vlen:
pnv = self.file.read(8)
sprevdata = self.file.read(8)
More information about the Zodb-checkins
mailing list