rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
def f(con, m=m):
def f(con, m=m, attr=attr):
def f(con, m=m): t=getattr(con._cache,attr) m[0]=m[0]+t m[1]=m[1]+1
f39f2055e988ba1e3df76ad857609df20d581115 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/f39f2055e988ba1e3df76ad857609df20d581115/DB.py
for oid in self._storage.undo(id): self.invalidate(oid)
storage=self._storage try: supportsTransactionalUndo = storage.supportsTransactionalUndo except AttributeError: supportsTransactionalUndo=0 else: supportsTransactionalUndo=supportsTransactionalUndo() if supportsTransactionalUndo: TransactionalUndo(self, id) else: for oid in storage.undo(id): self.invalidate(oid)
def undo(self, id): for oid in self._storage.undo(id): self.invalidate(oid)
f39f2055e988ba1e3df76ad857609df20d581115 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/f39f2055e988ba1e3df76ad857609df20d581115/DB.py
waiting.append(self.unlock, ())
waiting.append((self.unlock, ()))
def tpc_begin(self, id, user, description, ext): t=self._transaction if t is not None: if id == t.id: return else: raise StorageServerError( "Multiple simultaneous tpc_begin requests from the same " "client." ) storage=self.__storage if storage._transaction is not None: try: waiting=storage.__waiting except: waiting=storage.__waiting=[] waiting.append(self.unlock, ()) return 1 # Return a flag indicating a lock condition. self._transaction=t=Transaction() t.id=id t.user=user t.description=description storage.tpc_begin(t) self.__invalidated=[]
1cbeec85c5ec39b56d29835456323835d2d10998 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/1cbeec85c5ec39b56d29835456323835d2d10998/StorageServer.py
waiting.append(self.try_again_sync, (id, user, description, ext))
waiting.append((self.try_again_sync, (id, user, description, ext)))
def tpc_begin_sync(self, id, user, description, ext): if self.__closed: return t=self._transaction if t is not None and id == t.id: return storage=self.__storage if storage._transaction is None: self.try_again_sync(id, user, description, ext) else: try: waiting=storage.__waiting except: waiting=storage.__waiting=[] waiting.append(self.try_again_sync, (id, user, description, ext))
1cbeec85c5ec39b56d29835456323835d2d10998 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/1cbeec85c5ec39b56d29835456323835d2d10998/StorageServer.py
print err
s = str(err) if s: s = ": " + s print err.__class__.__name__ + s
def main(): host = None port = None unix = None write = 1 storage = '1' try: opts, args = getopt.getopt(sys.argv[1:], 'p:h:U:S:1', ['nowrite']) for o, a in opts: if o == '-p': port = int(a) elif o == '-h': host = a elif o == '-U': unix = a elif o == '-S': storage = a elif o == '--nowrite': write = 0 elif o == '-1': ZEO_VERSION = 1 except Exception, err: print err usage() if unix is not None: addr = unix else: if host is None: host = socket.gethostname() if port is None: usage() addr = host, port check_server(addr, storage, write)
6a1571aa798fc23c238b897615505076340ac2b8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/6a1571aa798fc23c238b897615505076340ac2b8/zeoup.py
print err
s = str(err) if s: s = ": " + s print err.__class__.__name__ + s
def main(): host = None port = None unix = None write = 1 storage = '1' try: opts, args = getopt.getopt(sys.argv[1:], 'p:h:U:S:1', ['nowrite']) for o, a in opts: if o == '-p': port = int(a) elif o == '-h': host = a elif o == '-U': unix = a elif o == '-S': storage = a elif o == '--nowrite': write = 0 elif o == '-1': ZEO_VERSION = 1 except Exception, err: print err usage() if unix is not None: addr = unix else: if host is None: host = socket.gethostname() if port is None: usage() addr = host, port check_server(addr, storage, write)
6a1571aa798fc23c238b897615505076340ac2b8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/6a1571aa798fc23c238b897615505076340ac2b8/zeoup.py
POSException.StorageSystemError):
POSException.StorageSystemError):
def panic(message, *data): message=message%data LOG('ZODB FS',PANIC,"%s ERROR: %s\n" % (packed_version, message)) raise CorruptedTransactionError, message
a1627c9451718e079aa248014709b67064a035ce /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/a1627c9451718e079aa248014709b67064a035ce/FileStorage.py
def main(): ZEOInstanceBuilder().run() print "All done."
9b5a2a8823c7114b825ff01deb44dd0fdbd94775 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9b5a2a8823c7114b825ff01deb44dd0fdbd94775/mkzeoinst.py
home = args[0] if not os.path.isabs(home): home = os.path.abspath(home)
instance_home = args[0] if not os.path.isabs(instance_home): instance_home = os.path.abspath(instance_home) for entry in sys.path: if os.path.exists(os.path.join(entry, 'Zope')): zope_home = entry break else: print "Can't find the Zope home (not in sys.path)" sys.exit(2)
def run(self): try: opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) except getopt.error, msg: print msg sys.exit(2) program = os.path.basename(sys.argv[0]) if opts: # There's only the help options, so just dump some help: msg = __doc__ % {"program": program} print msg sys.exit() if len(args) not in [1, 2]: print "Usage: %s home [port]" % program sys.exit(2) home = args[0] if not os.path.isabs(home): home = os.path.abspath(home) if args[1:]: port = int(args[1]) else: port = 9999 checkport(port) params = self.get_params(home, port) self.create(home, params)
9b5a2a8823c7114b825ff01deb44dd0fdbd94775 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9b5a2a8823c7114b825ff01deb44dd0fdbd94775/mkzeoinst.py
params = self.get_params(home, port) self.create(home, params) def get_params(self, home, port):
params = self.get_params(zope_home, instance_home, port) self.create(instance_home, params) def get_params(self, zope_home, instance_home, port):
def run(self): try: opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) except getopt.error, msg: print msg sys.exit(2) program = os.path.basename(sys.argv[0]) if opts: # There's only the help options, so just dump some help: msg = __doc__ % {"program": program} print msg sys.exit() if len(args) not in [1, 2]: print "Usage: %s home [port]" % program sys.exit(2) home = args[0] if not os.path.isabs(home): home = os.path.abspath(home) if args[1:]: port = int(args[1]) else: port = 9999 checkport(port) params = self.get_params(home, port) self.create(home, params)
9b5a2a8823c7114b825ff01deb44dd0fdbd94775 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9b5a2a8823c7114b825ff01deb44dd0fdbd94775/mkzeoinst.py
"home": home,
"zope_home": zope_home, "instance_home": instance_home,
def get_params(self, home, port): return { "package": "zeo", "PACKAGE": "ZEO", "home": home, "port": port, "python": sys.executable, "server": which("runzeo.py"), "zdrun": which("zdrun.py"), "zdctl": which("zdctl.py"), }
9b5a2a8823c7114b825ff01deb44dd0fdbd94775 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9b5a2a8823c7114b825ff01deb44dd0fdbd94775/mkzeoinst.py
"server": which("runzeo.py"), "zdrun": which("zdrun.py"), "zdctl": which("zdctl.py"),
def get_params(self, home, port): return { "package": "zeo", "PACKAGE": "ZEO", "home": home, "port": port, "python": sys.executable, "server": which("runzeo.py"), "zdrun": which("zdrun.py"), "zdctl": which("zdctl.py"), }
9b5a2a8823c7114b825ff01deb44dd0fdbd94775 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9b5a2a8823c7114b825ff01deb44dd0fdbd94775/mkzeoinst.py
poll_fun = asyncore.poll
poll_fun = poll
def loop(timeout=30.0, use_poll=0, map=None): """Invoke asyncore mainloop This function functions like the regular asyncore.loop() function except that it also triggers ThreadedAsync callback functions before starting the loop. """ if use_poll: if hasattr(select, 'poll'): poll_fun = asyncore.poll3 else: poll_fun = asyncore.poll2 else: poll_fun = asyncore.poll if map is None: map = asyncore.socket_map _start_loop(map) while map: poll_fun(timeout, map) _stop_loop()
0dc7ce85bb6b43173d62d343a0d78389c74a6922 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/0dc7ce85bb6b43173d62d343a0d78389c74a6922/LoopCallback.py
name = str(self.storage)
name = str(storage)
def slog(storage, msg, level=zLOG.INFO, error=None, pid=os.getpid()): name = getattr(storage, '__name__', None) if name is None: name = str(self.storage) zLOG.LOG("ZEO Server:%s:%s" % (pid, name), level, msg, error=error)
e2f5a9f798e024c101241507d75b4bce10abd7e2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e2f5a9f798e024c101241507d75b4bce10abd7e2/StorageServer.py
cserial, cdataptr, cver, cdata = self._undoDataInfo(
cserial, cdataptr, cdata, cver = self._undoDataInfo(
def _transactionalUndoRecord(self, oid, pos, serial, pre, version): """Get the indo information for a data record
95cb91701f7d86606224a80c504041b4cee33a74 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/95cb91701f7d86606224a80c504041b4cee33a74/FileStorage.py
def panic(message, *data): message=message%data LOG('ZODB FS',PANIC,"%s ERROR: %s\n" % (packed_version, message)) raise CorruptedTransactionError, message
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
class FileStorage: _packt=0 _transaction=None _serial=z64 def __init__(self, file_name, create=0, read_only=0, stop=None):
class FileStorage(BaseStorage.BaseStorage): _packt=z64 def __init__(self, file_name, create=0, read_only=0, stop=None, base=None):
def panic(message, *data): message=message%data LOG('ZODB FS',PANIC,"%s ERROR: %s\n" % (packed_version, message)) raise CorruptedTransactionError, message
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
self.__name__=file_name
BaseStorage.BaseStorage.__init__(self, file_name)
def __init__(self, file_name, create=0, read_only=0, stop=None):
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
self._index=index self._vindex=vindex self._tindex=tindex self._tvindex=tvindex self._indexpos=index.get self._vindexpos=vindex.get self._tappend=tindex.append l=bpthread.allocate_lock() self._a=l.acquire self._r=l.release l=bpthread.allocate_lock() self._ca=l.acquire self._cr=l.release
self._initIndex(index, vindex, tindex, tvindex) self._base=base
def __init__(self, file_name, create=0, read_only=0, stop=None):
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
return self.commitVersion(src, '', transaction, abort=1) def close(self): self._file.close() def commitVersion(self, src, dest, transaction, abort=None): if dest and abort: raise 'VersionCommitError', ( 'Internal error, can\'t abort to a version')
def abortVersion(self, src, transaction): # We are going to abort by simply storing back pointers.
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
self._a()
self._lock_acquire()
def abortVersion(self, src, transaction): # We are going to abort by simply storing back pointers.
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
srcpos=self._vindex.get(src, 0)
srcpos=self._vindex_get(src, 0)
def abortVersion(self, src, transaction): # We are going to abort by simply storing back pointers.
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
middle=p64(self._pos)+'\0'*10 here=tfile.tell()+self._pos+self._thl oids=[] appoids=oids.append while srcpos: seek(srcpos) h=read(58) oid=h[:8] if index[oid]==srcpos: tappend((oid,here)) appoids(oid) write(h[:16] + spos + middle + h[-16:-8]) here=here+50 spos=h[-8:] srcpos=u64(spos) self._tvindex[src]=0 return oids finally: self._r() def close(self): self._file.close() def commitVersion(self, src, dest, transaction): if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) self._a() try: file=self._file read=file.read seek=file.seek tfile=self._tfile write=tfile.write tappend=self._tappend index=self._index srcpos=self._vindex.get(src, 0) spos=p64(srcpos)
def abortVersion(self, src, transaction): # We are going to abort by simply storing back pointers.
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
sd=p64(self._vindex.get(dest, 0))
sd=p64(self._vindex_get(dest, 0))
def commitVersion(self, src, dest, transaction): # We are going to commit by simply storing back pointers. if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) self._a() try: file=self._file read=file.read seek=file.seek tfile=self._tfile write=tfile.write tappend=self._tappend index=self._index
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
current_oids={} current=current_oids.has_key t=None tstatus=' '
def commitVersion(self, src, dest, transaction): # We are going to commit by simply storing back pointers. if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) self._a() try: file=self._file read=file.read seek=file.seek tfile=self._tfile write=tfile.write tappend=self._tappend index=self._index
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
write(h[-16:-8]+sd+dest)
write(pnv+sd+dest)
def commitVersion(self, src, dest, transaction): # We are going to commit by simply storing back pointers. if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) self._a() try: file=self._file read=file.read seek=file.seek tfile=self._tfile write=tfile.write tappend=self._tappend index=self._index
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
write(spos)
write(abort and pnv or spos)
def commitVersion(self, src, dest, transaction): # We are going to commit by simply storing back pointers. if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) self._a() try: file=self._file read=file.read seek=file.seek tfile=self._tfile write=tfile.write tappend=self._tappend index=self._index
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
tvindex[src]=0
def commitVersion(self, src, dest, transaction): # We are going to commit by simply storing back pointers. if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) self._a() try: file=self._file read=file.read seek=file.seek tfile=self._tfile write=tfile.write tappend=self._tappend index=self._index
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
finally: self._r() def getName(self): return self.__name__
finally: self._lock_release()
def commitVersion(self, src, dest, transaction): # We are going to commit by simply storing back pointers. if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) self._a() try: file=self._file read=file.read seek=file.seek tfile=self._tfile write=tfile.write tappend=self._tappend index=self._index
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
def history(self, oid, version, length=1): pass
def _loada(self, oid, _index, file): "Read any version and return the version" pos=_index[oid] file.seek(pos) read=file.read h=read(42) doid,serial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h) if vlen: file.seek(16,1) version=read(vlen) else: version='' if plen != z64: return read(u64(plen)), version return _loadBack(file, oid, read(8))[0], version def _load(self, oid, version, _index, file): pos=_index[oid] file.seek(pos) read=file.read h=read(42) doid,serial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h) if doid != oid: raise CorruptedDataError, h if vlen: pnv=read(8) if (not version or len(version) != vlen or (read(8) and version != read(vlen)) ): return _loadBack(file, oid, pnv) if plen != z64: return read(u64(plen)), serial pnv=read(8) return _loadBack(file, oid, pnv)[0], serial
def getSize(self): return self._pos
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
self._a()
self._lock_acquire()
def load(self, oid, version, _stuff=None): self._a() try: pos=self._index[oid] file=self._file file.seek(pos) read=file.read h=read(42) doid,serial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h) if doid != oid: raise CorruptedDataError, h if vlen: pnv=read(8) # Read location of non-version data if (not version or len(version) != vlen or (read(8) # skip past version link and version != read(vlen)) ): return _loadBack(file, oid, pnv)
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
pos=self._index[oid] file=self._file file.seek(pos) read=file.read h=read(42) doid,serial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h) if doid != oid: raise CorruptedDataError, h if vlen: pnv=read(8) if (not version or len(version) != vlen or (read(8) and version != read(vlen)) ): return _loadBack(file, oid, pnv) if plen != z64: return read(u64(plen)), serial pnv=read(8) return _loadBack(file, oid, pnv)[0], serial finally: self._r()
try: return self._load(oid, version, self._index, self._file) except: if self._base is not None: return self._base.load(oid, version) raise finally: self._lock_release()
def load(self, oid, version, _stuff=None): self._a() try: pos=self._index[oid] file=self._file file.seek(pos) read=file.read h=read(42) doid,serial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h) if doid != oid: raise CorruptedDataError, h if vlen: pnv=read(8) # Read location of non-version data if (not version or len(version) != vlen or (read(8) # skip past version link and version != read(vlen)) ): return _loadBack(file, oid, pnv)
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
self._a()
self._lock_acquire()
def modifiedInVersion(self, oid): self._a() try: pos=self._index[oid] file=self._file seek=file.seek seek(pos) doid,serial,prev,tloc,vlen = unpack(">8s8s8s8sH", file.read(34)) if doid != oid: raise CorruptedDataError, h if vlen: seek(24,1) # skip plen, pnv, and pv return file.read(vlen) return '' finally: self._r()
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
finally: self._r() def new_oid(self, last=None): if last is None: self._a() try: last=self._oid d=ord(last[-1]) if d < 255: last=last[:-1]+chr(d+1) else: last=self.new_oid(last[:-1]) self._oid=last return last finally: self._r() else: d=ord(last[-1]) if d < 255: return last[:-1]+chr(d+1)+'\0'*(8-len(last)) else: return self.new_oid(last[:-1]) def pack(self, t, rf): pass
finally: self._lock_release()
def modifiedInVersion(self, oid): self._a() try: pos=self._index[oid] file=self._file seek=file.seek seek(pos) doid,serial,prev,tloc,vlen = unpack(">8s8s8s8sH", file.read(34)) if doid != oid: raise CorruptedDataError, h if vlen: seek(24,1) # skip plen, pnv, and pv return file.read(vlen) return '' finally: self._r()
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
self._a()
self._lock_acquire()
def store(self, oid, serial, data, version, transaction): if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction)
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
old=self._indexpos(oid, 0)
old=self._index_get(oid, 0)
def store(self, oid, serial, data, version, transaction): if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction)
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
pv=tvindex.get(version, 0) or self._vindexpos(version, 0)
pv=tvindex.get(version, 0) or self._vindex_get(version, 0)
def store(self, oid, serial, data, version, transaction): if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction)
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
finally: self._r() def registerDB(self, db, limit): pass def supportsUndo(self): return 0
finally: self._lock_release() def supportsUndo(self): return 1
def store(self, oid, serial, data, version, transaction): if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction)
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
def tpc_abort(self, transaction): self._a()
def _clear_temp(self): del self._tindex[:] self._tvindex.clear() self._tfile.seek(0) def _begin(self, tid, u, d, e): self._thl=23+len(u)+len(d)+len(e) def _finish(self, tid, u, d, e): file=self._file write=file.write tfile=self._tfile dlen=tfile.tell() tfile.seek(0) id=self._serial user, desc, ext = self._ude tlen=self._thl pos=self._pos file.seek(pos) tl=tlen+dlen stl=p64(tl) write(pack( ">8s" "8s" "c" "H" "H" "H" ,id, stl, ' ', len(user), len(desc), len(ext), )) if user: write(user) if desc: write(desc) if ext: write(ext) cp(tfile, file, dlen) write(stl) file.flush() self._pos=pos+tl+8 index=self._index for oid, pos in self._tindex: index[oid]=pos self._vindex.update(self._tvindex) def undo(self, transaction_id): self._lock_acquire()
def supportsVersions(self): return 1
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
if transaction is not self._transaction: return del self._tindex[:] self._transaction=None self._cr() finally: self._r() def tpc_begin(self, transaction): self._a() try: if self._transaction is transaction: return self._r() self._ca() self._a() self._transaction=transaction del self._tindex[:] self._tvindex.clear() self._tfile.seek(0) t=time.time() t=apply(TimeStamp,(time.gmtime(t)[:5]+(t%60,))) self._ts=t=t.laterThan(self._ts) self._serial=`t` user=transaction.user desc=transaction.description ext=transaction._extension if ext: ext=dumps(ext,1) else: ext="" self._thl=23+len(user)+len(desc)+len(ext) self._ude=user, desc, ext finally: self._r() def tpc_finish(self, transaction, f=None): self._a() try: if transaction is not self._transaction: return if f is not None: f() file=self._file write=file.write tfile=self._tfile dlen=tfile.tell() tfile.seek(0) id=self._serial user, desc, ext = self._ude self._ude=None tlen=self._thl pos=self._pos file.seek(pos) tl=tlen+dlen stl=p64(tl) write(pack( ">8s" "8s" "c" "H" "H" "H" ,id, stl, ' ', len(user), len(desc), len(ext), )) if user: write(user) if desc: write(desc) if ext: write(ext) cp(tfile, file, dlen) write(stl) file.flush() self._pos=pos+tl+8 tindex=self._tindex index=self._index for oid, pos in tindex: index[oid]=pos del tindex[:] tvindex=self._tvindex self._vindex.update(tvindex) tvindex.clear() self._transaction=None self._cr() finally: self._r() def undo(self, transaction_id): self._a() try:
transaction_id=base64.decodestring(transaction_id+'==\n') tid, tpos = transaction_id[:8], u64(transaction_id[8:]) packt=self._packt if packt is None or packt > tid: raise POSException.UndoError, ( 'Undo is currently disabled for database maintenance.<p>')
def tpc_abort(self, transaction): self._a() try: if transaction is not self._transaction: return del self._tindex[:] self._transaction=None self._cr() finally: self._r()
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
indexpos=self._indexpos
index_get=self._index_get
def undo(self, transaction_id): self._a() try: file=self._file seek=file.seek read=file.read indexpos=self._indexpos unpack=struct.unpack transaction_id=base64.decodestring(transaction_id+'==\n') tid, tpos = transaction_id[:8], u64(transaction_id[8:]) seek(tpos) h=read(23) if len(h) != 23 or h[:8] != tid: raise UndoError, 'Invalid undo transaction id' if h[16] == 'u': return if h[16] != ' ': raise UndoError, 'Undoable transaction' tl=u64(h[8:16]) ul,dl,el=unpack(">HHH", h[17:23]) tend=tpos+tl pos=tpos+23+ul+dl+el t=[] tappend=t.append while pos < tend: # Read the data records for this transaction seek(pos) h=read(42) oid,serial,sprev,stloc,vlen,splen = unpack(">8s8s8s8sH8s", h) plen=u64(splen) prev=u64(sprev) dlen=42+(plen or 8) if vlen: dlen=dlen+16+vlen if indexpos(oid,0) != pos: raise UndoError, 'Undoable transaction' pos=pos+dlen if pos > tend: raise UndoError, 'Undoable transaction' tappend((oid,prev))
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
transaction_id=base64.decodestring(transaction_id+'==\n') tid, tpos = transaction_id[:8], u64(transaction_id[8:])
def undo(self, transaction_id): self._a() try: file=self._file seek=file.seek read=file.read indexpos=self._indexpos unpack=struct.unpack transaction_id=base64.decodestring(transaction_id+'==\n') tid, tpos = transaction_id[:8], u64(transaction_id[8:]) seek(tpos) h=read(23) if len(h) != 23 or h[:8] != tid: raise UndoError, 'Invalid undo transaction id' if h[16] == 'u': return if h[16] != ' ': raise UndoError, 'Undoable transaction' tl=u64(h[8:16]) ul,dl,el=unpack(">HHH", h[17:23]) tend=tpos+tl pos=tpos+23+ul+dl+el t=[] tappend=t.append while pos < tend: # Read the data records for this transaction seek(pos) h=read(42) oid,serial,sprev,stloc,vlen,splen = unpack(">8s8s8s8sH8s", h) plen=u64(splen) prev=u64(sprev) dlen=42+(plen or 8) if vlen: dlen=dlen+16+vlen if indexpos(oid,0) != pos: raise UndoError, 'Undoable transaction' pos=pos+dlen if pos > tend: raise UndoError, 'Undoable transaction' tappend((oid,prev))
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
t=[] tappend=t.append
t={}
def undo(self, transaction_id): self._a() try: file=self._file seek=file.seek read=file.read indexpos=self._indexpos unpack=struct.unpack transaction_id=base64.decodestring(transaction_id+'==\n') tid, tpos = transaction_id[:8], u64(transaction_id[8:]) seek(tpos) h=read(23) if len(h) != 23 or h[:8] != tid: raise UndoError, 'Invalid undo transaction id' if h[16] == 'u': return if h[16] != ' ': raise UndoError, 'Undoable transaction' tl=u64(h[8:16]) ul,dl,el=unpack(">HHH", h[17:23]) tend=tpos+tl pos=tpos+23+ul+dl+el t=[] tappend=t.append while pos < tend: # Read the data records for this transaction seek(pos) h=read(42) oid,serial,sprev,stloc,vlen,splen = unpack(">8s8s8s8sH8s", h) plen=u64(splen) prev=u64(sprev) dlen=42+(plen or 8) if vlen: dlen=dlen+16+vlen if indexpos(oid,0) != pos: raise UndoError, 'Undoable transaction' pos=pos+dlen if pos > tend: raise UndoError, 'Undoable transaction' tappend((oid,prev))
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
if indexpos(oid,0) != pos:
if index_get(oid,0) != pos:
def undo(self, transaction_id): self._a() try: file=self._file seek=file.seek read=file.read indexpos=self._indexpos unpack=struct.unpack transaction_id=base64.decodestring(transaction_id+'==\n') tid, tpos = transaction_id[:8], u64(transaction_id[8:]) seek(tpos) h=read(23) if len(h) != 23 or h[:8] != tid: raise UndoError, 'Invalid undo transaction id' if h[16] == 'u': return if h[16] != ' ': raise UndoError, 'Undoable transaction' tl=u64(h[8:16]) ul,dl,el=unpack(">HHH", h[17:23]) tend=tpos+tl pos=tpos+23+ul+dl+el t=[] tappend=t.append while pos < tend: # Read the data records for this transaction seek(pos) h=read(42) oid,serial,sprev,stloc,vlen,splen = unpack(">8s8s8s8sH8s", h) plen=u64(splen) prev=u64(sprev) dlen=42+(plen or 8) if vlen: dlen=dlen+16+vlen if indexpos(oid,0) != pos: raise UndoError, 'Undoable transaction' pos=pos+dlen if pos > tend: raise UndoError, 'Undoable transaction' tappend((oid,prev))
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
tappend((oid,prev))
t[oid]=prev
def undo(self, transaction_id): self._a() try: file=self._file seek=file.seek read=file.read indexpos=self._indexpos unpack=struct.unpack transaction_id=base64.decodestring(transaction_id+'==\n') tid, tpos = transaction_id[:8], u64(transaction_id[8:]) seek(tpos) h=read(23) if len(h) != 23 or h[:8] != tid: raise UndoError, 'Invalid undo transaction id' if h[16] == 'u': return if h[16] != ' ': raise UndoError, 'Undoable transaction' tl=u64(h[8:16]) ul,dl,el=unpack(">HHH", h[17:23]) tend=tpos+tl pos=tpos+23+ul+dl+el t=[] tappend=t.append while pos < tend: # Read the data records for this transaction seek(pos) h=read(42) oid,serial,sprev,stloc,vlen,splen = unpack(">8s8s8s8sH8s", h) plen=u64(splen) prev=u64(sprev) dlen=42+(plen or 8) if vlen: dlen=dlen+16+vlen if indexpos(oid,0) != pos: raise UndoError, 'Undoable transaction' pos=pos+dlen if pos > tend: raise UndoError, 'Undoable transaction' tappend((oid,prev))
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
for oid, pos in t: index[oid]=pos finally: self._r()
for oid, pos in t.items(): index[oid]=pos return t.keys() finally: self._lock_release()
def undo(self, transaction_id): self._a() try: file=self._file seek=file.seek read=file.read indexpos=self._indexpos unpack=struct.unpack transaction_id=base64.decodestring(transaction_id+'==\n') tid, tpos = transaction_id[:8], u64(transaction_id[8:]) seek(tpos) h=read(23) if len(h) != 23 or h[:8] != tid: raise UndoError, 'Invalid undo transaction id' if h[16] == 'u': return if h[16] != ' ': raise UndoError, 'Undoable transaction' tl=u64(h[8:16]) ul,dl,el=unpack(">HHH", h[17:23]) tend=tpos+tl pos=tpos+23+ul+dl+el t=[] tappend=t.append while pos < tend: # Read the data records for this transaction seek(pos) h=read(42) oid,serial,sprev,stloc,vlen,splen = unpack(">8s8s8s8sH8s", h) plen=u64(splen) prev=u64(sprev) dlen=42+(plen or 8) if vlen: dlen=dlen+16+vlen if indexpos(oid,0) != pos: raise UndoError, 'Undoable transaction' pos=pos+dlen if pos > tend: raise UndoError, 'Undoable transaction' tappend((oid,prev))
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
self._a()
self._lock_acquire()
def undoLog(self, first, last, filter=None): self._a() try: pos=self._pos if pos < 39: return [] file=self._file seek=file.seek read=file.read unpack=struct.unpack strip=string.strip encode=base64.encodestring r=[] append=r.append i=0 while i < last and pos > 39: seek(pos-8) pos=pos-u64(read(8))-8 if i < first: continue seek(pos) h=read(23) tid, tl, status, ul, dl, el = unpack(">8s8scHHH", h) if status != ' ': continue u=ul and read(ul) or '' d=dl and read(dl) or '' d={'id': encode(tid+p64(pos))[:22], 'time': TimeStamp(tid).timeTime(), 'user_name': u, 'description': d} if el: try: e=loads(read(el)) d.update(e) except: pass if filter is None or filter(d): append(d) i=i+1 return r finally: self._r()
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
finally: self._r()
finally: self._lock_release()
def undoLog(self, first, last, filter=None): self._a() try: pos=self._pos if pos < 39: return [] file=self._file seek=file.seek read=file.read unpack=struct.unpack strip=string.strip encode=base64.encodestring r=[] append=r.append i=0 while i < last and pos > 39: seek(pos-8) pos=pos-u64(read(8))-8 if i < first: continue seek(pos) h=read(23) tid, tl, status, ul, dl, el = unpack(">8s8scHHH", h) if status != ' ': continue u=ul and read(ul) or '' d=dl and read(dl) or '' d={'id': encode(tid+p64(pos))[:22], 'time': TimeStamp(tid).timeTime(), 'user_name': u, 'description': d} if el: try: e=loads(read(el)) d.update(e) except: pass if filter is None or filter(d): append(d) i=i+1 return r finally: self._r()
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
return not self._vindex.get(version, 0)
self._lock_acquire() try: index=self._index file=self._file seek=file.seek read=file.read srcpos=self._vindex_get(version, 0) t=tstatus=None while srcpos: seek(srcpos) oid=read(8) if index[oid]==srcpos: return 0 h=read(50) tloc=h[16:24] if t != tloc: t=tloc seek(u64(t)+16) tstatus=read(1) if tstatus != 'u': return 1 spos=h[-8:] srcpos=u64(spos) return 1 finally: self._lock_release()
def versionEmpty(self, version): return not self._vindex.get(version, 0)
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
if max: return self._vindex.keys()[:max] return self._vindex.keys()
r=[] a=r.append for version in self._vindex.keys()[:max]: if self.versionEmpty(version): continue a(version) if max and len(r) >= max: return r return r def pack(self, t, referencesf): """Copy data from the current database file to a packed file Non-current records from transactions with time-stamp strings less than packtss are ommitted. As are all undone records. Also, data back pointers that point before packtss are resolved and the associated data are copied, since the old records are not copied. """ packing=1 locked=0 _lock_acquire=self._lock_acquire _lock_release=self._lock_release index, vindex, tindex, tvindex = self._newIndexes() name=self.__name__ file=open(name, 'r+b') stop=`apply(TimeStamp, time.gmtime(t)[:5]+(t%60,))` try: _lock_acquire() self._packt=stop _lock_release() packpos, maxoid, ltid = read_index( file, name, index, vindex, tindex, stop) rootl=[z64] pop=rootl.pop pindex={} referenced=pindex.has_key _load=self._load _loada=self._loada v=None while rootl: oid=pop() if referenced(oid): continue try: p, v = _loada(oid, index, file) referencesf(p, rootl) if v: p, serial = _load(oid, '', index, file) referencesf(p, rootl) pindex[oid]=index[oid] except: pindex[oid]=0 error('Bad reference to %s', `(oid,v)`) spackpos=p64(packpos) index, vindex, tindex, tvindex = self._newIndexes() ofile=open(name+'.pack', 'w+b') nvindex={} seek=file.seek read=file.read oseek=ofile.seek write=ofile.write tappend=tindex.append index_get=index.get vindex_get=vindex.get pindex_get=pindex.get pv=z64 offset=0 pos=opos=4 oseek(0) write(packed_version) pnv=None while 1: if packing and pos >= packpos: offset=pos-opos if offset <= 0: ofile.close() file.close() os.remove(name+'.pack') return packing=0 _lock_acquire() locked=1 self._packt=None seek(pos) h=read(23) if len(h) < 23: break tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el tl=u64(stl) tpos=pos tend=tpos+tl if status=='u': pos=tend+8 continue otpos=opos write(h) thl=ul+dl+el h=read(thl) if len(h) != thl: raise 'Pack Error', opos write(h) thl=23+thl pos=tpos+thl opos=otpos+thl status=' ' while pos < tend: seek(pos) h=read(42) oid,serial,sprev,stloc,vlen,splen = unpack( ">8s8s8s8sH8s", h) plen=u64(splen) dlen=42+(plen or 8) if vlen: dlen=dlen+16+vlen if packing and pindex_get(oid,0) != pos: pos=pos+dlen status='p' continue pnv=u64(read(8)) seek(8,1) version=read(vlen) pv=p64(vindex_get(version, 0)) vindex[version]=opos else: if packing: ppos=pindex_get(oid, 0) if ppos != pos: if not ppos: pos=pos+dlen status='p' continue seek(ppos) ph=read(42) pdoid,ps,pp,pt,pvlen,pplen = unpack( ">8s8s8s8sH8s", ph) if not pvlen: pos=pos+dlen status='p' continue pnv=read(8) pnv=_loadBackPOS(file, oid, pnv) if pnv > pos: pos=pos+dlen status='p' continue nvindex[oid]=opos tappend((oid,opos)) opos=opos+dlen pos=pos+dlen if plen: p=read(plen) else: p=read(8) if packing: p, serial = _loadBack(file, oid, p) plen=len(p) opos=opos+plen-8 splen=p64(plen) else: p=u64(p) if p < packpos: if pindex[oid]==p: p=index[oid] else: p=nvindex[oid] else: p=p-offset p=p64(p) sprev=p64(index_get(oid,0)) write(pack(">8s8s8s8sH8s", oid,serial,sprev,p64(otpos),vlen,splen)) if vlen: if not pnv: write(z64) else: if pnv < packpos: pnv=nvindex[oid] else: pnv=pnv-offset write(p64(pnv)) write(pv) write(version) write(p) pos=pos+8 if locked: _lock_release() locked=0 for oid, p in tindex: index[oid]=p del tindex[:] otl=opos-otpos if otl != tl: if otl==thl: opos=otpos oseek(opos) else: oseek(otpos+8) otl=p64(otl) write(otl+status) oseek(opos) write(otl) opos=opos+8 else: write(p64(otl)) opos=opos+8 if not packing: _lock_acquire() locked=1 name=self.__name__ ofile.flush() ofile.close() file.close() self._file.close() try: os.remove(name) except: self._file=open(name,'r+b') raise os.rename(name+'.pack', name) self._file=open(name,'r+b') self._initIndex(index, vindex, tindex, tvindex) self._pos=opos finally: if locked: _lock_release() _lock_acquire() self._packt=z64 _lock_release()
def versions(self, max=None): if max: return self._vindex.keys()[:max] return self._vindex.keys()
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
indexpos=index.get
index_get=index.get
def read_index(file, name, index, vindex, tindex, stop='\377'*8): indexpos=index.get vndexpos=vindex.get tappend=tindex.append read=file.read seek=file.seek seek(0,2) file_size=file.tell() seek(0) if file_size: if file_size < 4: raise FileStorageFormatError, file.name if read(4) != packed_version: raise FileStorageFormatError, name else: file.write(packed_version) pos=4 unpack=struct.unpack tpos=0 maxoid=ltid=z64 tid='\0'*7+'\1' while 1: # Read the transaction record h=read(23) if not h: break if len(h) != 23: warn('%s truncated at %s', name, pos) seek(pos) file.truncate() break tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el if tid <= ltid: warn("%s time-stamp reduction at %s", name, pos) ltid=tid tl=u64(stl) if tl+pos+8 > file_size: # Hm, the data were truncated. They may also be corrupted, # in which case, we don't want to totally lose the data. warn("%s truncated, possibly due to damaged records at %s", name, pos) try: i=0 while 1: if os.path.exists('%s.tr%s' % (name, i)): i=i+1 else: o=open('%s.tr%s' % (name, i),'wb') seek(pos) cp(file, o, file_size-pos) o.close() break except: error("couldn\'t write truncated data for %s", name) raise POSException.StorageSystemError, ( "Couldn't save truncated data") seek(pos) file.truncate() break if status not in ' up': warn('%s has invalid status, %s, at %s', name, status, pos) if ul > tl or dl > tl or el > tl: panic('%s has invalid transaction header at %s', name, pos) if tid >= stop: break tpos=pos tend=tpos+tl if status=='u': # Undone transaction, skip it pos=tpos+tl seek(pos) h=read(8) if h != stl: panic('%s has inconsistent transaction length at %s', name, pos) pos=pos+8 continue pos=tpos+23+ul+dl+el while pos < tend: # Read the data records for this transaction seek(pos) h=read(42) oid,serial,sprev,stloc,vlen,splen = unpack(">8s8s8s8sH8s", h) prev=u64(sprev) tloc=u64(stloc) plen=u64(splen) dlen=42+(plen or 8) tappend((oid,pos)) if vlen: dlen=dlen+16+vlen seek(8,1) pv=u64(read(8)) version=read(vlen) # Jim says: "It's just not worth the bother." #if vndexpos(version, 0) != pv: # panic("%s incorrect previous version pointer at %s", # name, pos) vindex[version]=pos if pos+dlen > tend or tloc != tpos: panic("%s data record exceeds transaction record at %s", name, pos) if indexpos(oid,0) != prev: panic("%s incorrect previous pointer at %s", name, pos) pos=pos+dlen if pos != tend: panic("%s data records don't add up at %s",name,tpos) # Read the (intentionally redundant) transaction length seek(pos) h=read(8) if h != stl: panic("%s redundant transaction length check failed at %s", name, pos) pos=pos+8 for oid, p in tindex: maxoid=max(maxoid,oid) index[oid]=p # Record the position del tindex[:] _checkVindex(file, index, vindex) return pos, maxoid, ltid
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
pos=tpos+tl seek(pos)
seek(tend)
def read_index(file, name, index, vindex, tindex, stop='\377'*8): indexpos=index.get vndexpos=vindex.get tappend=tindex.append read=file.read seek=file.seek seek(0,2) file_size=file.tell() seek(0) if file_size: if file_size < 4: raise FileStorageFormatError, file.name if read(4) != packed_version: raise FileStorageFormatError, name else: file.write(packed_version) pos=4 unpack=struct.unpack tpos=0 maxoid=ltid=z64 tid='\0'*7+'\1' while 1: # Read the transaction record h=read(23) if not h: break if len(h) != 23: warn('%s truncated at %s', name, pos) seek(pos) file.truncate() break tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el if tid <= ltid: warn("%s time-stamp reduction at %s", name, pos) ltid=tid tl=u64(stl) if tl+pos+8 > file_size: # Hm, the data were truncated. They may also be corrupted, # in which case, we don't want to totally lose the data. warn("%s truncated, possibly due to damaged records at %s", name, pos) try: i=0 while 1: if os.path.exists('%s.tr%s' % (name, i)): i=i+1 else: o=open('%s.tr%s' % (name, i),'wb') seek(pos) cp(file, o, file_size-pos) o.close() break except: error("couldn\'t write truncated data for %s", name) raise POSException.StorageSystemError, ( "Couldn't save truncated data") seek(pos) file.truncate() break if status not in ' up': warn('%s has invalid status, %s, at %s', name, status, pos) if ul > tl or dl > tl or el > tl: panic('%s has invalid transaction header at %s', name, pos) if tid >= stop: break tpos=pos tend=tpos+tl if status=='u': # Undone transaction, skip it pos=tpos+tl seek(pos) h=read(8) if h != stl: panic('%s has inconsistent transaction length at %s', name, pos) pos=pos+8 continue pos=tpos+23+ul+dl+el while pos < tend: # Read the data records for this transaction seek(pos) h=read(42) oid,serial,sprev,stloc,vlen,splen = unpack(">8s8s8s8sH8s", h) prev=u64(sprev) tloc=u64(stloc) plen=u64(splen) dlen=42+(plen or 8) tappend((oid,pos)) if vlen: dlen=dlen+16+vlen seek(8,1) pv=u64(read(8)) version=read(vlen) # Jim says: "It's just not worth the bother." #if vndexpos(version, 0) != pv: # panic("%s incorrect previous version pointer at %s", # name, pos) vindex[version]=pos if pos+dlen > tend or tloc != tpos: panic("%s data record exceeds transaction record at %s", name, pos) if indexpos(oid,0) != prev: panic("%s incorrect previous pointer at %s", name, pos) pos=pos+dlen if pos != tend: panic("%s data records don't add up at %s",name,tpos) # Read the (intentionally redundant) transaction length seek(pos) h=read(8) if h != stl: panic("%s redundant transaction length check failed at %s", name, pos) pos=pos+8 for oid, p in tindex: maxoid=max(maxoid,oid) index[oid]=p # Record the position del tindex[:] _checkVindex(file, index, vindex) return pos, maxoid, ltid
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
pos=pos+8
pos=tend+8
def read_index(file, name, index, vindex, tindex, stop='\377'*8): indexpos=index.get vndexpos=vindex.get tappend=tindex.append read=file.read seek=file.seek seek(0,2) file_size=file.tell() seek(0) if file_size: if file_size < 4: raise FileStorageFormatError, file.name if read(4) != packed_version: raise FileStorageFormatError, name else: file.write(packed_version) pos=4 unpack=struct.unpack tpos=0 maxoid=ltid=z64 tid='\0'*7+'\1' while 1: # Read the transaction record h=read(23) if not h: break if len(h) != 23: warn('%s truncated at %s', name, pos) seek(pos) file.truncate() break tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el if tid <= ltid: warn("%s time-stamp reduction at %s", name, pos) ltid=tid tl=u64(stl) if tl+pos+8 > file_size: # Hm, the data were truncated. They may also be corrupted, # in which case, we don't want to totally lose the data. warn("%s truncated, possibly due to damaged records at %s", name, pos) try: i=0 while 1: if os.path.exists('%s.tr%s' % (name, i)): i=i+1 else: o=open('%s.tr%s' % (name, i),'wb') seek(pos) cp(file, o, file_size-pos) o.close() break except: error("couldn\'t write truncated data for %s", name) raise POSException.StorageSystemError, ( "Couldn't save truncated data") seek(pos) file.truncate() break if status not in ' up': warn('%s has invalid status, %s, at %s', name, status, pos) if ul > tl or dl > tl or el > tl: panic('%s has invalid transaction header at %s', name, pos) if tid >= stop: break tpos=pos tend=tpos+tl if status=='u': # Undone transaction, skip it pos=tpos+tl seek(pos) h=read(8) if h != stl: panic('%s has inconsistent transaction length at %s', name, pos) pos=pos+8 continue pos=tpos+23+ul+dl+el while pos < tend: # Read the data records for this transaction seek(pos) h=read(42) oid,serial,sprev,stloc,vlen,splen = unpack(">8s8s8s8sH8s", h) prev=u64(sprev) tloc=u64(stloc) plen=u64(splen) dlen=42+(plen or 8) tappend((oid,pos)) if vlen: dlen=dlen+16+vlen seek(8,1) pv=u64(read(8)) version=read(vlen) # Jim says: "It's just not worth the bother." #if vndexpos(version, 0) != pv: # panic("%s incorrect previous version pointer at %s", # name, pos) vindex[version]=pos if pos+dlen > tend or tloc != tpos: panic("%s data record exceeds transaction record at %s", name, pos) if indexpos(oid,0) != prev: panic("%s incorrect previous pointer at %s", name, pos) pos=pos+dlen if pos != tend: panic("%s data records don't add up at %s",name,tpos) # Read the (intentionally redundant) transaction length seek(pos) h=read(8) if h != stl: panic("%s redundant transaction length check failed at %s", name, pos) pos=pos+8 for oid, p in tindex: maxoid=max(maxoid,oid) index[oid]=p # Record the position del tindex[:] _checkVindex(file, index, vindex) return pos, maxoid, ltid
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
if indexpos(oid,0) != prev:
if index_get(oid,0) != prev:
def read_index(file, name, index, vindex, tindex, stop='\377'*8): indexpos=index.get vndexpos=vindex.get tappend=tindex.append read=file.read seek=file.seek seek(0,2) file_size=file.tell() seek(0) if file_size: if file_size < 4: raise FileStorageFormatError, file.name if read(4) != packed_version: raise FileStorageFormatError, name else: file.write(packed_version) pos=4 unpack=struct.unpack tpos=0 maxoid=ltid=z64 tid='\0'*7+'\1' while 1: # Read the transaction record h=read(23) if not h: break if len(h) != 23: warn('%s truncated at %s', name, pos) seek(pos) file.truncate() break tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el if tid <= ltid: warn("%s time-stamp reduction at %s", name, pos) ltid=tid tl=u64(stl) if tl+pos+8 > file_size: # Hm, the data were truncated. They may also be corrupted, # in which case, we don't want to totally lose the data. warn("%s truncated, possibly due to damaged records at %s", name, pos) try: i=0 while 1: if os.path.exists('%s.tr%s' % (name, i)): i=i+1 else: o=open('%s.tr%s' % (name, i),'wb') seek(pos) cp(file, o, file_size-pos) o.close() break except: error("couldn\'t write truncated data for %s", name) raise POSException.StorageSystemError, ( "Couldn't save truncated data") seek(pos) file.truncate() break if status not in ' up': warn('%s has invalid status, %s, at %s', name, status, pos) if ul > tl or dl > tl or el > tl: panic('%s has invalid transaction header at %s', name, pos) if tid >= stop: break tpos=pos tend=tpos+tl if status=='u': # Undone transaction, skip it pos=tpos+tl seek(pos) h=read(8) if h != stl: panic('%s has inconsistent transaction length at %s', name, pos) pos=pos+8 continue pos=tpos+23+ul+dl+el while pos < tend: # Read the data records for this transaction seek(pos) h=read(42) oid,serial,sprev,stloc,vlen,splen = unpack(">8s8s8s8sH8s", h) prev=u64(sprev) tloc=u64(stloc) plen=u64(splen) dlen=42+(plen or 8) tappend((oid,pos)) if vlen: dlen=dlen+16+vlen seek(8,1) pv=u64(read(8)) version=read(vlen) # Jim says: "It's just not worth the bother." #if vndexpos(version, 0) != pv: # panic("%s incorrect previous version pointer at %s", # name, pos) vindex[version]=pos if pos+dlen > tend or tloc != tpos: panic("%s data record exceeds transaction record at %s", name, pos) if indexpos(oid,0) != prev: panic("%s incorrect previous pointer at %s", name, pos) pos=pos+dlen if pos != tend: panic("%s data records don't add up at %s",name,tpos) # Read the (intentionally redundant) transaction length seek(pos) h=read(8) if h != stl: panic("%s redundant transaction length check failed at %s", name, pos) pos=pos+8 for oid, p in tindex: maxoid=max(maxoid,oid) index[oid]=p # Record the position del tindex[:] _checkVindex(file, index, vindex) return pos, maxoid, ltid
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
def _loadBack(file, oid, back): seek=file.seek read=file.read while 1: old=u64(back) if not old: raise KeyError, oid seek(old) h=read(42) doid,serial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h) #if doid != oid: # panic(lambda x: None, # "%s version record back pointer points to " # "invalid record as %s", name, back) if vlen: seek(vlen+16,1) if plen != z64: return read(u64(plen)), serial back=read(8) # We got a back pointer!
c717e4737d70d5e206ed68763b0a0252266215ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/c717e4737d70d5e206ed68763b0a0252266215ca/FileStorage.py
pos = 4
pos = 4L
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print "Recovering", inp, "into", outp if os.path.exists(outp) and not force: die("%s exists" % outp) f = open(inp, "rb") if f.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") f.seek(0,2) file_size = f.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 undone = 0 pos = 4 ltid = None while pos: try: npos, txn, tid = read_txn_header(f, pos, file_size, outp, ltid) except EOFError: break except (KeyboardInterrupt, SystemExit): raise except Exception, err: print "error reading txn header:", err if not verbose: progress(prog1) pos = scan(f, pos) if verbose > 1: print "looking for valid txn header at", pos continue ltid = tid if txn is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = txn.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ("Time stamps out of order %s, %s" % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ("Time stamps back in order %s" % (t)) ok = 1 ofs.tpc_begin(txn, tid, txn.status) if verbose: print "begin", pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in txn: if verbose > 1: if r.data is None: l = "bp" else: l = len(r.data) print "%7d %s %s" % (u64(r.oid), l, r.version) s = ofs.restore(r.oid, r.serial, r.data, r.version, r.data_txn, txn) nrec += 1 except (KeyboardInterrupt, SystemExit): raise except Exception, err: if partial and nrec: ofs._status = "p" ofs.tpc_vote(txn) ofs.tpc_finish(txn) if verbose: print "partial" else: ofs.tpc_abort(txn) print "error copying transaction:", err if not verbose: progress(prog1) pos = scan(f, pos) if verbose > 1: print "looking for valid txn header at", pos else: ofs.tpc_vote(txn) ofs.tpc_finish(txn) if verbose: print "finish" sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
21058f0d29a3ec9524eb6649b4d14c7de7577dc0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/21058f0d29a3ec9524eb6649b4d14c7de7577dc0/fsrecover.py
"src/ZEO/runzeo.py", "src/ZEO/zeopasswd.py", "src/ZEO/mkzeoinst.py", "src/ZEO/zeoctl.py",
def BTreeExtension(flavor): key = flavor[0] value = flavor[1] name = "BTrees._%sBTree" % flavor sources = ["src/BTrees/_%sBTree.c" % flavor] kwargs = {"include_dirs": include} if flavor != "fs": kwargs["depends"] = (base_btrees_depends + [KEY_H % _flavors[key], VALUE_H % _flavors[value]]) if key != "O": kwargs["define_macros"] = [('EXCLUDE_INTSET_SUPPORT', None)] return Extension(name, sources, **kwargs)
e20e5b29b38a7d2eabb133c25cef38e5c5a8e01f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e20e5b29b38a7d2eabb133c25cef38e5c5a8e01f/setup.py
self.strategy.tpc_abort()
strategy = self.strategy strategy.tpc_abort()
def tpc_abort(self, id): if not self._check_tid(id): return self.strategy.tpc_abort() self._transaction = None self.strategy = None self._handle_waiting()
f89b404bcec6e43c49a946f2141591dce1efa810 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/f89b404bcec6e43c49a946f2141591dce1efa810/StorageServer.py
self._handle_waiting()
if isinstance(strategy, ImmediateCommitStrategy): self._handle_waiting()
def tpc_abort(self, id): if not self._check_tid(id): return self.strategy.tpc_abort() self._transaction = None self.strategy = None self._handle_waiting()
f89b404bcec6e43c49a946f2141591dce1efa810 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/f89b404bcec6e43c49a946f2141591dce1efa810/StorageServer.py
'opened': c._opened and ctime(c._opened),
'opened': o and ("%s (%.2fs)" % (ctime(o), t-o)),
def connectionDebugInfo(self): r=[] pools,pooll=self._pools for version, (pool, allocated, lock) in pools.items(): for c in allocated: r.append({ 'opened': c._opened and ctime(c._opened), 'info': c._debug_info, 'version': version, }) return r
cfccb5da10708611bb5d1c6bd1ffe70f9d09cb98 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/cfccb5da10708611bb5d1c6bd1ffe70f9d09cb98/DB.py
class ISized(ICollection): def __len__(): """Return the number of items in the set""" class IReadSequence(Interface.Base): def __getitem__(index): """Return an item for a given index."""
class IReadSequence(Interface.Standard.Sequence):
def __nonzero__(): """Check if the collection is non-empty.
70f54df688f1f24815738cc3f414b25689a001b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/70f54df688f1f24815738cc3f414b25689a001b5/Interfaces.py
class IKeySequence(IKeyed, ISized):
class IKeySequence(IKeyed, Interface.Standard.Sized):
def update(seq): """Add the items from the given sequence to the set"""
70f54df688f1f24815738cc3f414b25689a001b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/70f54df688f1f24815738cc3f414b25689a001b5/Interfaces.py
class IDictionaryIsh(IKeyed, ISized): def __getitem__(key): """Get the value for the given key Raise a key error if the key if not in the collection. """ def get(key, default=None): """Get the value for the given key Raise a key error if the key if not in the collection and no default is specified. Return the default if specified and the key is not in the collection. """ def __setitem__(key, value): """Set the value for the given key""" def __delitem__(key): """delete the value for the given key Raise a key error if the key if not in the collection."""
class IDictionaryIsh(IKeyed, Interface.Standard.MinimalDictionary):
def __getitem__(index): """Return the key in the given index position
70f54df688f1f24815738cc3f414b25689a001b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/70f54df688f1f24815738cc3f414b25689a001b5/Interfaces.py
class IMerge(Interfaces.Base):
class IMerge(Interface.Base):
def insert(key, value): """Insert a key and value into the collection.
70f54df688f1f24815738cc3f414b25689a001b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/70f54df688f1f24815738cc3f414b25689a001b5/Interfaces.py
Interface.assertTypeImplements(OOBTree.OOSet, ISet) Interface.assertTypeImplements(OOBTree.OOTreeSet, ITreeSet) Interface.assertTypeImplements(OOBTree.OOBucket, IDictionaryIsh) Interface.assertTypeImplements(OOBTree.OOBTree, IBTree)
OOBTree.OOSet.__implements__=ISet OOBTree.OOTreeSet.__implements__=ITreeSet OOBTree.OOBucket.__implements__=IDictionaryIsh OOBTree.OOBTree.__implements__=IBTree
def weightedIntersection(c1, c2, weight1=1, weight2=1): """Compute the weighted intersection of c1 and c2.
70f54df688f1f24815738cc3f414b25689a001b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/70f54df688f1f24815738cc3f414b25689a001b5/Interfaces.py
class FileStorageError: pass class FileStorageFormatError(FileStorageError, POSException.StorageError):
class FileStorageError(POSException.StorageError): pass class FileStorageFormatError(FileStorageError):
def panic(message, *data): message=message%data LOG('ZODB FS',PANIC,"%s ERROR: %s\n" % (packed_version, message)) raise CorruptedTransactionError, message
3dc5f44ee6e70343dff189bf1cbf55c6b0274821 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/3dc5f44ee6e70343dff189bf1cbf55c6b0274821/FileStorage.py
file.seek(16,1)
nv = read(8) != z64 file.seek(8,1)
def _loada(self, oid, _index, file): "Read any version and return the version" pos=_index[oid] file.seek(pos) read=file.read h=read(42) doid,serial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h) if vlen: file.seek(16,1) version=read(vlen) else: version=''
3dc5f44ee6e70343dff189bf1cbf55c6b0274821 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/3dc5f44ee6e70343dff189bf1cbf55c6b0274821/FileStorage.py
if plen != z64: return read(u64(plen)), version return _loadBack(file, oid, read(8))[0], version
nv=0 if plen != z64: return read(u64(plen)), version, nv return _loadBack(file, oid, read(8))[0], version, nv
def _loada(self, oid, _index, file): "Read any version and return the version" pos=_index[oid] file.seek(pos) read=file.read h=read(42) doid,serial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h) if vlen: file.seek(16,1) version=read(vlen) else: version=''
3dc5f44ee6e70343dff189bf1cbf55c6b0274821 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/3dc5f44ee6e70343dff189bf1cbf55c6b0274821/FileStorage.py
p, v = _loada(oid, index, file)
p, v, nv = _loada(oid, index, file)
def pack(self, t, referencesf): """Copy data from the current database file to a packed file Non-current records from transactions with time-stamp strings less than packtss are ommitted. As are all undone records. Also, data back pointers that point before packtss are resolved and the associated data are copied, since the old records are not copied. """
3dc5f44ee6e70343dff189bf1cbf55c6b0274821 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/3dc5f44ee6e70343dff189bf1cbf55c6b0274821/FileStorage.py
if v:
if nv:
def pack(self, t, referencesf): """Copy data from the current database file to a packed file Non-current records from transactions with time-stamp strings less than packtss are ommitted. As are all undone records. Also, data back pointers that point before packtss are resolved and the associated data are copied, since the old records are not copied. """
3dc5f44ee6e70343dff189bf1cbf55c6b0274821 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/3dc5f44ee6e70343dff189bf1cbf55c6b0274821/FileStorage.py
def pack(self, t, referencesf): """Copy data from the current database file to a packed file Non-current records from transactions with time-stamp strings less than packtss are ommitted. As are all undone records. Also, data back pointers that point before packtss are resolved and the associated data are copied, since the old records are not copied. """
3dc5f44ee6e70343dff189bf1cbf55c6b0274821 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/3dc5f44ee6e70343dff189bf1cbf55c6b0274821/FileStorage.py
def pack(self, t, referencesf): """Copy data from the current database file to a packed file Non-current records from transactions with time-stamp strings less than packtss are ommitted. As are all undone records. Also, data back pointers that point before packtss are resolved and the associated data are copied, since the old records are not copied. """
3dc5f44ee6e70343dff189bf1cbf55c6b0274821 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/3dc5f44ee6e70343dff189bf1cbf55c6b0274821/FileStorage.py
def pack(self, t, referencesf): """Copy data from the current database file to a packed file Non-current records from transactions with time-stamp strings less than packtss are ommitted. As are all undone records. Also, data back pointers that point before packtss are resolved and the associated data are copied, since the old records are not copied. """
3dc5f44ee6e70343dff189bf1cbf55c6b0274821 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/3dc5f44ee6e70343dff189bf1cbf55c6b0274821/FileStorage.py
def read_index(file, name, index, vindex, tindex, stop='\377'*8): index_get=index.get vndexpos=vindex.get tappend=tindex.append read=file.read seek=file.seek seek(0,2) file_size=file.tell() seek(0) if file_size: if file_size < 4: raise FileStorageFormatError, file.name if read(4) != packed_version: raise FileStorageFormatError, name else: file.write(packed_version) pos=4 unpack=struct.unpack tpos=0 maxoid=ltid=z64 tid='\0'*7+'\1' while 1: # Read the transaction record h=read(23) if not h: break if len(h) != 23: warn('%s truncated at %s', name, pos) seek(pos) file.truncate() break tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el if tid <= ltid: warn("%s time-stamp reduction at %s", name, pos) ltid=tid tl=u64(stl) if tl+pos+8 > file_size or status=='c': # Hm, the data were truncated or the checkpoint flag wasn't # cleared. They may also be corrupted, # in which case, we don't want to totally lose the data. warn("%s truncated, possibly due to damaged records at %s", name, pos) _truncate(file, name, pos) break if status not in ' up': warn('%s has invalid status, %s, at %s', name, status, pos) if ul > tl or dl > tl or el > tl or tl < (23+ul+dl+el): # We're in trouble. Find out if this is bad data in the # middle of the file, or just a turd that Win 9x dropped # at the end when the system crashed. # Skip to the end and read what should be the transaction length # of the last transaction. seek(-8, 2) rtl=u64(read(8)) # Now check to see if the redundant transaction length is # reasonable: if file_size - rtl < pos or rtl < 23: nearPanic('%s has invalid transaction header at %s', name, pos) warn("It appears that there is invalid data at the end of the " "file, possibly due to a system crash. %s truncated " "to recover from bad data at end." % name) _truncate(file, name, pos) break else: panic('%s has invalid transaction header at %s', name, pos) if tid >= stop: break tpos=pos tend=tpos+tl if status=='u': # Undone transaction, skip it seek(tend) h=read(8) if h != stl: panic('%s has inconsistent transaction length at %s', name, pos) pos=tend+8 continue pos=tpos+23+ul+dl+el while pos < tend: # Read the data records for this transaction seek(pos) h=read(42) oid,serial,sprev,stloc,vlen,splen = unpack(">8s8s8s8sH8s", h) prev=u64(sprev) tloc=u64(stloc) plen=u64(splen) dlen=42+(plen or 8) tappend((oid,pos)) # print u64(oid), pos, vlen, plen, index.get(oid,'?') if vlen: dlen=dlen+16+vlen seek(8,1) pv=u64(read(8)) version=read(vlen) # Jim says: "It's just not worth the bother." #if vndexpos(version, 0) != pv: # panic("%s incorrect previous version pointer at %s", # name, pos) vindex[version]=pos if pos+dlen > tend or tloc != tpos: panic("%s data record exceeds transaction record at %s", name, pos) if index_get(oid,0) != prev: panic("%s incorrect previous pointer at %s", name, pos) pos=pos+dlen if pos != tend: panic("%s data records don't add up at %s",name,tpos) # Read the (intentionally redundant) transaction length seek(pos) h=read(8) if h != stl: panic("%s redundant transaction length check failed at %s", name, pos) pos=pos+8 for oid, p in tindex: maxoid=max(maxoid,oid) index[oid]=p # Record the position del tindex[:] return pos, maxoid, ltid
3dc5f44ee6e70343dff189bf1cbf55c6b0274821 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/3dc5f44ee6e70343dff189bf1cbf55c6b0274821/FileStorage.py
def _bad_message(self, msg): # Establish a connection, then send the server an ill-formatted # request. Verify that the connection is closed and that it is # possible to establish a new connection.
19f15f097171914c9041f6030a78776a815d9a67 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/19f15f097171914c9041f6030a78776a815d9a67/ConnectionTests.py
def checkMultiStorageTransaction(self):
def NOcheckMultiStorageTransaction(self):
def checkMultiStorageTransaction(self): # Configuration parameters (larger values mean more likely deadlocks) N = 2 # These don't *have* to be all the same, but it's convenient this way self.nservers = N self.nthreads = N self.ntrans = N self.nobj = N
19f15f097171914c9041f6030a78776a815d9a67 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/19f15f097171914c9041f6030a78776a815d9a67/ConnectionTests.py
if verbose:
if verbose or code in (0x00, 0x70):
def main(): # Parse options verbose = 0 dostats = 1 try: opts, args = getopt.getopt(sys.argv[1:], "vS") except getopt.error, msg: usage(msg) return 2 for o, a in opts: if o == "-v": verbose = 1 if o == "-S": dostats = 0 verbose = 1 if len(args) != 1: usage("exactly one file argument required") return 2 filename = args[0] # Open file try: f = open(filename, "rb") except IOError, msg: print "can't open %s: %s" % (filename, msg) return 1 # Read file, gathering statistics, and printing each record if verbose rt0 = time.time() bycode = {} records = 0 versions = 0 t0 = te = None datarecords = 0 datasize = 0L file0 = file1 = 0 while 1: r = f.read(24) if len(r) < 24: break records += 1 ts, code, oid, serial = struct.unpack(">ii8s8s", r) if t0 is None: t0 = ts te = ts dlen, code = code & 0x7fffff00, code & 0xff if dlen: datarecords += 1 datasize += dlen version = '-' if code & 0x80: version = 'V' versions += 1 current = code & 1 if current: file1 += 1 else: file0 += 1 code = code & 0x7e bycode[code] = bycode.get(code, 0) + 1 if verbose: print "%s %d %02x %016x %016x %1s %s" % ( time.ctime(ts)[4:-5], current, code, U64(oid), U64(serial), version, dlen and str(dlen) or "") bytes = f.tell() f.close() rte = time.time() # Error if nothing was read if not records: print >>sys.stderr, "No records processed" return 1 # Print statistics if dostats: if verbose: print print "Read %s records (%s bytes) in %.1f seconds" % ( addcommas(records), addcommas(bytes), rte-rt0) print "Version: %s records" % addcommas(versions) print "First time: %s" % time.ctime(t0) print "Last time: %s" % time.ctime(te) print "Duration: %s seconds" % addcommas(te-t0) print "File stats: %s in file 0; %s in file 1" % ( addcommas(file0), addcommas(file1)) print "Data recs: %s (%.1f%%), average size %.1f KB" % ( addcommas(datarecords), 100.0 * datarecords / records, datasize / 1024.0 / datarecords) print codes = bycode.keys() codes.sort() print "%13s %4s %s" % ("Count", "Code", "Function (action)") for code in codes: print "%13s %02x %s" % ( addcommas(bycode.get(code, 0)), code, explain.get(code) or "*** unknown code ***")
7dd84cc1ddfee84a8c28768c379062ad59fe02e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/7dd84cc1ddfee84a8c28768c379062ad59fe02e6/stats.py
if verbose: print
print
def main(): # Parse options verbose = 0 dostats = 1 try: opts, args = getopt.getopt(sys.argv[1:], "vS") except getopt.error, msg: usage(msg) return 2 for o, a in opts: if o == "-v": verbose = 1 if o == "-S": dostats = 0 verbose = 1 if len(args) != 1: usage("exactly one file argument required") return 2 filename = args[0] # Open file try: f = open(filename, "rb") except IOError, msg: print "can't open %s: %s" % (filename, msg) return 1 # Read file, gathering statistics, and printing each record if verbose rt0 = time.time() bycode = {} records = 0 versions = 0 t0 = te = None datarecords = 0 datasize = 0L file0 = file1 = 0 while 1: r = f.read(24) if len(r) < 24: break records += 1 ts, code, oid, serial = struct.unpack(">ii8s8s", r) if t0 is None: t0 = ts te = ts dlen, code = code & 0x7fffff00, code & 0xff if dlen: datarecords += 1 datasize += dlen version = '-' if code & 0x80: version = 'V' versions += 1 current = code & 1 if current: file1 += 1 else: file0 += 1 code = code & 0x7e bycode[code] = bycode.get(code, 0) + 1 if verbose: print "%s %d %02x %016x %016x %1s %s" % ( time.ctime(ts)[4:-5], current, code, U64(oid), U64(serial), version, dlen and str(dlen) or "") bytes = f.tell() f.close() rte = time.time() # Error if nothing was read if not records: print >>sys.stderr, "No records processed" return 1 # Print statistics if dostats: if verbose: print print "Read %s records (%s bytes) in %.1f seconds" % ( addcommas(records), addcommas(bytes), rte-rt0) print "Version: %s records" % addcommas(versions) print "First time: %s" % time.ctime(t0) print "Last time: %s" % time.ctime(te) print "Duration: %s seconds" % addcommas(te-t0) print "File stats: %s in file 0; %s in file 1" % ( addcommas(file0), addcommas(file1)) print "Data recs: %s (%.1f%%), average size %.1f KB" % ( addcommas(datarecords), 100.0 * datarecords / records, datasize / 1024.0 / datarecords) print codes = bycode.keys() codes.sort() print "%13s %4s %s" % ("Count", "Code", "Function (action)") for code in codes: print "%13s %02x %s" % ( addcommas(bycode.get(code, 0)), code, explain.get(code) or "*** unknown code ***")
7dd84cc1ddfee84a8c28768c379062ad59fe02e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/7dd84cc1ddfee84a8c28768c379062ad59fe02e6/stats.py
h, v = unpack(">II", s)
h, v = struct.unpack(">II", s)
def U64(s): h, v = unpack(">II", s) return (long(h) << 32) + v
7dd84cc1ddfee84a8c28768c379062ad59fe02e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/7dd84cc1ddfee84a8c28768c379062ad59fe02e6/stats.py
s.connect(('', 42000))
s.connect(('localhost', 42000))
def get_monitor_output(self): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('', 42000)) L = [] while 1: buf = s.recv(8192) if buf: L.append(buf) else: break s.close() return "".join(L)
3b6a81109ca7cbe2d26943e0ff06eb086a004592 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/3b6a81109ca7cbe2d26943e0ff06eb086a004592/testMonitor.py
consider the int() of this valua to be significant.
consider the int() of this value to be significant.
def LOG(subsystem, severity, summary, detail='', error=None, reraise=None): """Log some information The required arguments are: subsystem -- The subsystem generating the message (e.g. ZODB) severity -- The "severity" of the event. This may be an integer or a floating point number. Logging back ends may consider the int() of this valua to be significant. For example, a backend may consider any severity whos integer value is WARNING to be a warning. summary -- A short summary of the event detail -- A detailed description error -- A three-element tuple consisting of an error type, value, and traceback. If provided, then a summary of the error is added to the detail. reraise -- If provided with a true value, then the error given by error is reraised. """ if _call_initialize: initialize() log_write(subsystem, severity, summary, detail, error) if reraise and error: raise error[0], error[1], error[2]
3fcd20bdd4b6720f2520d2772d1b7acd432a2460 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/3fcd20bdd4b6720f2520d2772d1b7acd432a2460/__init__.py
"""Insert a key and value into the colelction.
"""Insert a key and value into the collection.
def insert(key, value): """Insert a key and value into the colelction.
aeab8c93a7c0a5bda69374c81d8b24424f026a2b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/aeab8c93a7c0a5bda69374c81d8b24424f026a2b/Interfaces.py
zLOG.LOG('ZEO Server', zLOG.INFO, 'Serving %s:\t%s' % kv)
LOG('ZEO Server', INFO, 'Serving %s:\t%s' % kv)
def handler(signum, frame, storages=storages, die=signal.SIGTERM): for storage in storages.values(): try: storage.close() finally: pass if signum==dir: sys.exit(0) else: sys.exit(1)
b57d55e2f6e81d57914c84317992c5405ddd644c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/b57d55e2f6e81d57914c84317992c5405ddd644c/start.py
auth_filename=self.options.auth_database,
auth_database=self.options.auth_database,
def create_server(self): from ZEO.StorageServer import StorageServer self.server = StorageServer( self.options.address, self.storages, read_only=self.options.read_only, invalidation_queue_size=self.options.invalidation_queue_size, transaction_timeout=self.options.transaction_timeout, monitor_address=self.options.monitor_address, auth_protocol=self.options.auth_protocol, auth_filename=self.options.auth_database, # XXX option spelling auth_realm=self.options.auth_realm)
220b5ca0ff1822ae49d0ad8dc03e72b825f12944 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/220b5ca0ff1822ae49d0ad8dc03e72b825f12944/runzeo.py
def testReadConflictIgnored(self):
def checkReadConflictIgnored(self):
def testReadConflictIgnored(self): # Test that an application that catches a read conflict and # continues can not commit the transaction later. root = self._db.open().root() root["real_data"] = real_data = PersistentDict() root["index"] = index = PersistentDict()
b196e7d1cc01a98bb2538b5a1fbab66e345f00a0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/b196e7d1cc01a98bb2538b5a1fbab66e345f00a0/testZODB.py
root["real_data"] = real_data = PersistentDict() root["index"] = index = PersistentDict() real_data["a"] = PersistentDict({"indexed_value": 0}) real_data["b"] = PersistentDict({"indexed_value": 1}) index[1] = PersistentDict({"b": 1}) index[0] = PersistentDict({"a": 1})
root["real_data"] = real_data = PersistentMapping() root["index"] = index = PersistentMapping() real_data["a"] = PersistentMapping({"indexed_value": 0}) real_data["b"] = PersistentMapping({"indexed_value": 1}) index[1] = PersistentMapping({"b": 1}) index[0] = PersistentMapping({"a": 1})
def testReadConflictIgnored(self): # Test that an application that catches a read conflict and # continues can not commit the transaction later. root = self._db.open().root() root["real_data"] = real_data = PersistentDict() root["index"] = index = PersistentDict()
b196e7d1cc01a98bb2538b5a1fbab66e345f00a0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/b196e7d1cc01a98bb2538b5a1fbab66e345f00a0/testZODB.py
cn2.getTransaction().commit()
get_transaction().commit()
def testReadConflictIgnored(self): # Test that an application that catches a read conflict and # continues can not commit the transaction later. root = self._db.open().root() root["real_data"] = real_data = PersistentDict() root["index"] = index = PersistentDict()
b196e7d1cc01a98bb2538b5a1fbab66e345f00a0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/b196e7d1cc01a98bb2538b5a1fbab66e345f00a0/testZODB.py
self.assertRaises(ConflictError, get_transaction().commit)
self.assertRaises(ConflictError, cn2.getTransaction().commit)
def testReadConflictIgnored(self): # Test that an application that catches a read conflict and # continues can not commit the transaction later. root = self._db.open().root() root["real_data"] = real_data = PersistentDict() root["index"] = index = PersistentDict()
b196e7d1cc01a98bb2538b5a1fbab66e345f00a0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/b196e7d1cc01a98bb2538b5a1fbab66e345f00a0/testZODB.py
self.sub1._p_jar = SubTransactionJar(errors='tpc_finish') self.nosub1.modify() self.sub1.modify(nojar=1)
for sub in self.sub1, self.sub2: sub._p_jar = SubTransactionJar(errors='tpc_finish') sub.modify(nojar=1) self.nosub1.modify()
def testExceptionInTpcFinish(self):
87b49138068d7b09413d83d983876ec44c830b2a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/87b49138068d7b09413d83d983876ec44c830b2a/testTransaction.py
self.sub1._p_jar = SubTransactionJar(errors='tpc_finish') self.nosub1.modify() self.sub1.modify(nojar=1)
for sub in self.sub1, self.sub2: sub._p_jar = SubTransactionJar(errors='tpc_finish') sub.modify(nojar=1) self.nosub1.modify()
def testHoserStoppage(self):
87b49138068d7b09413d83d983876ec44c830b2a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/87b49138068d7b09413d83d983876ec44c830b2a/testTransaction.py
has_mac = 0
def handle_read(self): self.__input_lock.acquire() try: # Use a single __inp buffer and integer indexes to make this fast. try: d = self.recv(8192) except socket.error, err: if err[0] in expected_socket_read_errors: return raise if not d: return
a0d97c9c0701a12df8ea85991da665028dda979f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/a0d97c9c0701a12df8ea85991da665028dda979f/smac.py
self.locked = True
self.locked = 1
def pack(self): # Pack copies all data reachable at the pack time or later. # # Copying occurs in two phases. In the first phase, txns # before the pack time are copied if the contain any reachable # data. In the second phase, all txns after the pack time # are copied. # # Txn and data records contain pointers to previous records. # Because these pointers are stored as file offsets, they # must be updated when we copy data. # XXX Need to add sanity checking to pack
41713b26e7d5b49ec6bf01be485f3d5c731feb7c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/41713b26e7d5b49ec6bf01be485f3d5c731feb7c/fspack.py
(self.tid, length, self.status, self.user_len, self.descr_len,
(self.tid, self.length, self.status, self.user_len, self.descr_len,
def _read_header(self): self._file.seek(self._pos) self._hdr = self._file.read(TRANS_HDR_LEN) (self.tid, length, self.status, self.user_len, self.descr_len, self.ext_len) = struct.unpack(TRANS_HDR, self._hdr) self.length = u64(length)
52dc3a30671c23470e83304f3c1c8091af606f30 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/52dc3a30671c23470e83304f3c1c8091af606f30/fstools.py
self.length = u64(length)
def _read_header(self): self._file.seek(self._pos) self._hdr = self._file.read(TRANS_HDR_LEN) (self.tid, length, self.status, self.user_len, self.descr_len, self.ext_len) = struct.unpack(TRANS_HDR, self._hdr) self.length = u64(length)
52dc3a30671c23470e83304f3c1c8091af606f30 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/52dc3a30671c23470e83304f3c1c8091af606f30/fstools.py
def main():
def test_suite():
def main(): TIOBTree = makeSuite(TestIOBTrees, 'test') TOOBTree = makeSuite(TestOOBTrees, 'test') TOIBTree = makeSuite(TestOIBTrees, 'test') TIIBTree = makeSuite(TestIIBTrees, 'test') TIOSet = makeSuite(TestIOSets, 'test') TOOSet = makeSuite(TestOOSets, 'test') TOISet = makeSuite(TestIOSets, 'test') TIISet = makeSuite(TestOOSets, 'test') TIOTreeSet = makeSuite(TestIOTreeSets, 'test') TOOTreeSet = makeSuite(TestOOTreeSets, 'test') TOITreeSet = makeSuite(TestIOTreeSets, 'test') TIITreeSet = makeSuite(TestOOTreeSets, 'test') TIOBucket = makeSuite(TestIOBuckets, 'test') TOOBucket = makeSuite(TestOOBuckets, 'test') TOIBucket = makeSuite(TestOIBuckets, 'test') TIIBucket = makeSuite(TestIIBuckets, 'test') alltests = TestSuite((TIOSet, TOOSet, TOISet, TIISet, TIOTreeSet, TOOTreeSet, TOITreeSet, TIITreeSet, TIOBucket, TOOBucket, TOIBucket, TIIBucket, TOOBTree, TIOBTree, TOIBTree, TIIBTree)) runner = TextTestRunner() runner.run(alltests)
11d192345cbe0fbfc32322caad074a329978e352 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/11d192345cbe0fbfc32322caad074a329978e352/testBTrees.py
l = filter(lambda x, l1=l1: x not in l1, l2) l = l + filter(lambda x, l2=l2: x not in l2, l1) return l
l1=list(l1) l2=list(l2) l = filter(lambda x, l1=l1: x not in l1, l2) l = l + filter(lambda x, l2=l2: x not in l2, l1) return l
def lsubtract(l1, l2): l = filter(lambda x, l1=l1: x not in l1, l2) l = l + filter(lambda x, l2=l2: x not in l2, l1) return l
11d192345cbe0fbfc32322caad074a329978e352 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/11d192345cbe0fbfc32322caad074a329978e352/testBTrees.py
if __name__ == '__main__': main()
if __name__=='__main__': if len(sys.argv) > 1: globals()[sys.argv[1]]() else: main()
def realseq(itemsob): return map(lambda x: x, itemsob)
11d192345cbe0fbfc32322caad074a329978e352 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/11d192345cbe0fbfc32322caad074a329978e352/testBTrees.py
assert root['t'] == t
assert list(root['t'].items()) == list(t.items())
def testLoadAndStore(self): t = self.t try: root = self._getRoot() root['t'] = t get_transaction().commit() except: self._closeDB(root) self._delDB() raise
5e23fe69eee7bf646e82443419dcdf4b156da2cc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/5e23fe69eee7bf646e82443419dcdf4b156da2cc/testBTrees.py
assert root['t'] == t
assert list(root['t'].items()) == list(t.items())
def testGhostUnghost(self): t = self.t try: root = self._getRoot() root['t'] = t get_transaction().commit() except: self._closeDB(root) self._delDB() raise
5e23fe69eee7bf646e82443419dcdf4b156da2cc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/5e23fe69eee7bf646e82443419dcdf4b156da2cc/testBTrees.py
assert len(t) == 1000, len(t)
assert len(t) == 10000, len(t)
def testLen(self): # should sets know their length? t = self.t r = xrange(10000) for x in r: t.insert(x) assert len(t) == 1000, len(t)
5e23fe69eee7bf646e82443419dcdf4b156da2cc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/5e23fe69eee7bf646e82443419dcdf4b156da2cc/testBTrees.py