Commit 5472857b authored by Marius Gedminas's avatar Marius Gedminas

Fix ResourceWarning in fstail.py

parent 2d181876
......@@ -26,21 +26,21 @@ except ImportError:
from sha import sha as sha1
def main(path, ntxn):
f = open(path, "rb")
f.seek(0, 2)
th = prev_txn(f)
i = ntxn
while th and i > 0:
hash = sha1(th.get_raw_data()).digest()
l = len(str(th.get_timestamp())) + 1
th.read_meta()
print("%s: hash=%s" % (th.get_timestamp(),
binascii.hexlify(hash).decode()))
print(("user=%r description=%r length=%d offset=%d"
% (th.user, th.descr, th.length, th.get_data_offset())))
print()
th = th.prev_txn()
i -= 1
with open(path, "rb") as f:
f.seek(0, 2)
th = prev_txn(f)
i = ntxn
while th and i > 0:
hash = sha1(th.get_raw_data()).digest()
l = len(str(th.get_timestamp())) + 1
th.read_meta()
print("%s: hash=%s" % (th.get_timestamp(),
binascii.hexlify(hash).decode()))
print(("user=%r description=%r length=%d offset=%d"
% (th.user, th.descr, th.length, th.get_data_offset())))
print()
th = th.prev_txn()
i -= 1
def Main():
ntxn = 10
......
......@@ -11,7 +11,7 @@ We have to prepare a FileStorage first:
>>> from ZODB.DB import DB
>>> import transaction
>>> from tempfile import mktemp
>>> storagefile = mktemp()
>>> storagefile = mktemp(suffix='.fs')
>>> base_storage = FileStorage(storagefile)
>>> database = DB(base_storage)
>>> connection1 = database.open()
......@@ -33,6 +33,7 @@ Now lets have a look at the last transactions of this FileStorage:
Now clean up the storage again:
>>> import os
>>> connection1.close()
>>> base_storage.close()
>>> os.unlink(storagefile)
>>> os.unlink(storagefile+'.index')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment