rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
'user_name': u, 'description': d} if el: try: e=loads(read(el)) d.update(e) except: pass | 'user_name': u, 'description': d} d.update(e) | def undoLog(self, first=0, last=-20, filter=None): if last < 0: last=first-last+1 self._lock_acquire() try: packt=self._packt if packt is None: raise UndoError( 'Undo is currently disabled for database maintenance.<p>') pos=self._pos if pos < 39: return [] file=self._file seek=file.seek read=file.read unpack=struct.unp... |
oid=object._p_oid __traceback_info__=oid p, serial = self._storage.load(oid, self._version) file=StringIO(p) unpickler=Unpickler(file) unpickler.persistent_load=self._persistent_load copy = unpickler.load() klass, args = copy if klass is not ExtensionKlass: LOG('ZODB',ERROR, "Unexpected klass when setting class stat... | try: oid=object._p_oid __traceback_info__=oid p, serial = self._storage.load(oid, self._version) file=StringIO(p) unpickler=Unpickler(file) unpickler.persistent_load=self._persistent_load copy = unpickler.load() klass, args = copy if klass is not ExtensionKlass: LOG('ZODB',ERROR, "Unexpected klass when setting class... | def setklassstate(self, object, tt=type(()), ct=type(HelperClass)): oid=object._p_oid __traceback_info__=oid p, serial = self._storage.load(oid, self._version) file=StringIO(p) unpickler=Unpickler(file) unpickler.persistent_load=self._persistent_load |
print modulename, classname | def find_global(modulename, classname): """Helper for this test suite to get special PersistentMapping""" print modulename, classname if classname == "PersistentMapping": class PersistentMapping: def __setstate__(self, state): self.__dict__.update(state) return PersistentMapping else: __import__(modulename) mod = sys.... | |
def log(message, level=zLOG.INFO, label="StorageServer:%s" % os.getpid(), error=None): zLOG.LOG(label, level, message, error=error) | _label = "ZSS" def set_label(): global _label _label = "ZSS:%s" % os.getpid() def log(message, level=zLOG.INFO, label=None, error=None): zLOG.LOG(label or _label, level, message, error=error) | def log(message, level=zLOG.INFO, label="StorageServer:%s" % os.getpid(), error=None): zLOG.LOG(label, level, message, error=error) |
def _log(self, msg, level=zLOG.INFO, error=None, pid=os.getpid()): | def _log(self, msg, level=zLOG.INFO, error=None): | def _log(self, msg, level=zLOG.INFO, error=None, pid=os.getpid()): name = getattr(self.__storage, '__name__', None) if name is None: name = str(self.__storage) zLOG.LOG("ZEOStorage:%s:%s" % (pid, name), level, msg, error=error) |
zLOG.LOG("ZEOStorage:%s:%s" % (pid, name), level, msg, error=error) | zLOG.LOG("%s:%s" % (_label, name), level, msg, error=error) | def _log(self, msg, level=zLOG.INFO, error=None, pid=os.getpid()): name = getattr(self.__storage, '__name__', None) if name is None: name = str(self.__storage) zLOG.LOG("ZEOStorage:%s:%s" % (pid, name), level, msg, error=error) |
os.unlink(path) | need_to_delete = 1 for dummy in range(5): try: os.unlink(path) except: time.sleep(0.5) else: need_to_delete = 0 break if need_to_delete: os.unlink(path) | def tearDown(self): """Try to cause the tests to halt""" zLOG.LOG("testZEO", zLOG.INFO, "tearDown() %s" % self.id()) for p in self.conf_paths: os.remove(p) if getattr(self, '_storage', None) is not None: self._storage.close() if hasattr(self._storage, 'cleanup'): self._storage.cleanup() for adminaddr in self._servers: ... |
pool_lock.acquire() | if not pool_lock.acquire(0): result = DB.open(self, version, transaction, temporary, force, waitflag) self._a() return result | def open(self, version='', transaction=None, temporary=0, force=None, waitflag=1, mvcc=True, txn_mgr=None, synch=True): """Return a database Connection for use by application code. |
c = pool[-1] del pool[-1] | c = pool.pop() | def open(self, version='', transaction=None, temporary=0, force=None, waitflag=1, mvcc=True, txn_mgr=None, synch=True): """Return a database Connection for use by application code. |
import zLog.MinimalLogger zLog.MinimalLogger._log.initialize() | import zLOG.MinimalLogger zLOG.MinimalLogger._log.initialize() | def rotate_logs(): import zLOG # There hasn't been a clear way to reinitialize the MinimalLogger. # I'll checkin the public initialize() method soon, but also try some # other strategies for older Zope installs :-(. init = getattr(zLOG, 'initialize', None) if init is not None: init() return # This will work if the mini... |
"pwd module is not available." % uid)) | "pwd module is not available." % arg)) | def set_uid(arg): """Try to set uid and gid based on -u argument. This will only work if this script is run by root. """ try: import pwd except ImportError: LOG('ZEO/start.py', INFO, ("Can't set uid to %s." "pwd module is not available." % uid)) return try: gid = None try: arg = int(arg) except: # conversion could rai... |
self.__has_mac = True | self.__has_mac = 0 | def __init__(self, sock, addr, map=None, debug=None): self.addr = addr if debug is not None: self._debug = debug elif not hasattr(self, '_debug'): self._debug = __debug__ # __input_lock protects __inp, __input_len, __state, __msg_size self.__input_lock = threading.Lock() self.__inp = None # None, a single String, or a ... |
resouces. The only works under Unix, and if ZServer is started by root. | resouces. The only works under Unix, and if the storage server is started by root. | def main(argv): me=argv[0] sys.path[:]==filter(None, sys.path) sys.path.insert(0, directory(me, 2)) args=[] last='' for a in argv[1:]: if (a[:1] != '-' and string.find(a, '=') > 0 and last != '-S' # lame, sorry ): a=string.split(a,'=') os.environ[a[0]]=string.join(a[1:],'=') continue args.append(a) last=a INSTANCE_HO... |
and call it to minotor the storage. | and call it to monitor the storage. | def info(RESPONSE): RESPONSE['Content-type']= 'text/plain' |
__version__='$Revision: 1.6 $'[11:-2] import base64, POSException, BTree, BaseStorage, time, string, utils | __version__='$Revision: 1.7 $'[11:-2] import base64, time, string from ZODB import POSException, BaseStorage, utils | def info(RESPONSE): RESPONSE['Content-type']= 'text/plain' |
self._data=BTree.BTree() | self._data=OOBTree.OOBTree() | def __init__(self, name='Demo Storage', base=None, quota=None): |
tindex.append([oid, serial, r, None, p]) | if dest: new_vdata = dest, vdata[1] else: new_vdata = None tindex.append([oid, serial, r, new_vdata, p]) | def commitVersion(self, src, dest, transaction): if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) self._lock_acquire() try: v=self._vindex.get(src, None) if v is None: return tindex=self._tindex oids=[] for r in v.values(): oid, serial, pre, vdata, p = r oids.appe... |
try: oid, serial, pre, vdata, p = self._index[oid] except: if self._base: return self._base.load(oid, '') | try: oid, serial, pre, vdata, p = self._index[oid] except KeyError: if self._base: return self._base.load(oid, '') | def load(self, oid, version): self._lock_acquire() try: try: oid, serial, pre, vdata, p = self._index[oid] except: if self._base: return self._base.load(oid, '') raise KeyError, oid |
if s > self._quota: | if self._quota is not None and s > self._quota: | def store(self, oid, serial, data, version, transaction): if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) |
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 | r = [] for v in self._vindex.keys(): if self.versionEmpty(v): continue r.append(v) if max is not None and len(r) >= max: break | def versions(self, max=None): 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 |
if ((invalid(oid) and not hasattr(object, '_p_resolveConflict')) or invalid(None)): | if invalid(oid) and not hasattr(object, '_p_resolveConflict'): | def commit(self, object, transaction): if object is self: # We registered ourself. Execute a commit action, if any. if self.__onCommitActions is not None: method_name, args, kw = self.__onCommitActions.pop(0) apply(getattr(self, method_name), (transaction,) + args, kw) return oid = object._p_oid invalid = self._invali... |
if ( (invalid(oid) and not hasattr(object, '_p_resolveConflict')) or invalid(None) ): | if invalid(oid) and not hasattr(object, '_p_resolveConflict'): | # def persistent_id(object, |
invalid = self._invalid if invalid(oid) or invalid(None): | if self._invalid(oid): | def setstate(self, object): oid = object._p_oid |
if self._invalid(None): raise ConflictError("transaction already invalidated") | def tpc_begin(self, transaction, sub=None): if self._invalid(None): # Some nitwit invalidated everything! raise ConflictError("transaction already invalidated") self._invalidating = [] self._creating = [] | |
continue | def main(path): fs = FileStorage(path, read_only=1) noload = {} for oid in fs._index.keys(): try: data, serial = fs.load(oid, "") except: print "oid %s failed to load" % hex(u64(oid)) if VERBOSE: traceback.print_exc() noload[oid] = 1 # XXX If we get here after we've already loaded objects # that refer to this one, we ... | |
level=zLOG.DEBUG) | level=zLOG.TRACE) | def message_input(self, message): """Decoding an incoming message and dispatch it""" # XXX Not sure what to do with errors that reach this level. # Need to catch ZRPCErrors in handle_reply() and # handle_request() so that they get back to the client. try: msgid, flags, name, args = self.marshal.decode(message) except D... |
log("send msg: %d, %d, %s, ..." % (msgid, flags, method)) | log("send msg: %d, %d, %s, ..." % (msgid, flags, method), zLOG.TRACE) | def send_call(self, method, args, flags): # send a message and return its msgid self.__msgid_lock.acquire() try: msgid = self.msgid self.msgid = self.msgid + 1 finally: self.__msgid_lock.release() if __debug__: log("send msg: %d, %d, %s, ..." % (msgid, flags, method)) buf = self.marshal.encode(msgid, flags, method, arg... |
if i < first: continue | if i < first: i = i+1 continue | def undoLog(self, first, last, filter=None): self._lock_acquire() try: packt=self._packt if packt is None: raise POSException.UndoError, ( 'Undo is currently disabled for database maintenance.<p>') pos=self._pos if pos < 39: return [] file=self._file seek=file.seek read=file.read unpack=struct.unpack strip=string.strip... |
def checkPackVersionsInPast(self): pass def checkPackAfterUndoDeletion(self): pass | def check_periodic_save_index(self): | |
tl=u64(rstl) | tl=U64(rstl) | def _sane(self, index, pos): """Sanity check saved index data by reading the last undone trans |
opos=pos+23+ul+dl+el | opos=pos+(23+ul+dl+el) | def _sane(self, index, pos): """Sanity check saved index data by reading the last undone trans |
tloc=u64(stloc) plen=u64(splen) | tloc=U64(stloc) plen=U64(splen) | def _sane(self, index, pos): """Sanity check saved index data by reading the last undone trans |
if vlen: dlen=dlen+16+vlen | if vlen: dlen=dlen+(16+vlen) | def _sane(self, index, pos): """Sanity check saved index data by reading the last undone trans |
pos=info.get('pos', None) | pos=long(info.get('pos', None)) | def _restore_index(self): """Load the database index from a file to support quick startup """ file_name=self.__name__ index_name=file_name+'.index' try: f=open(index_name,'rb') except: return None p=Unpickler(f) |
self._save_index() | try: self._save_index() except: pass | def close(self): self._file.close() self._lock_file.close() self._tfile.close() self._save_index() |
here=tfile.tell()+self._pos+self._thl | here=self._pos+(tfile.tell()+self._thl) | def commitVersion(self, src, dest, transaction, abort=None): # We are going to commit by simply storing back pointers. |
seek(u64(t)+16) | seek(U64(t)+16) | def commitVersion(self, src, dest, transaction, abort=None): # We are going to commit by simply storing back pointers. |
srcpos=u64(spos) | srcpos=U64(spos) | def commitVersion(self, src, dest, transaction, abort=None): # We are going to commit by simply storing back pointers. |
if plen != z64: return read(u64(plen)), version, nv | if plen != z64: return read(U64(plen)), 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: nv = read(8) != z64 file.seek(8,1) # Skip previous version record pointer version=read(vlen) else: version='' nv=0 |
if plen != z64: return read(u64(plen)), serial | if plen != z64: return read(U64(plen)), serial | 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) # Read location of non-version data if (not version or len(version) != vlen or (read(8) # ski... |
pos=u64(prev) | pos=U64(prev) | def loadSerial(self, oid, serial): self._lock_acquire() try: _index=self._index file=self._file seek=file.seek read=file.read pos=_index[oid] while 1: seek(pos) h=read(42) doid,dserial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h) if doid != oid: raise CorruptedDataError, h if dserial == serial: break # Yeee ha! # Ke... |
if plen != z64: return read(u64(plen)) | if plen != z64: return read(U64(plen)) | def loadSerial(self, oid, serial): self._lock_acquire() try: _index=self._index file=self._file seek=file.seek read=file.read pos=_index[oid] while 1: seek(pos) h=read(42) doid,dserial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h) if doid != oid: raise CorruptedDataError, h if dserial == serial: break # Yeee ha! # Ke... |
here=tfile.tell()+pos+self._thl | here=pos+(tfile.tell()+self._thl) | def store(self, oid, serial, data, version, transaction): if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) |
if quota is not None and tfile.tell()+pos+self._thl > quota: | if quota is not None and pos+(tfile.tell()+self._thl) > quota: | def store(self, oid, serial, data, version, transaction): if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) |
self._nextpos=0 def tpc_vote(self, transaction): if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) self._lock_acquire() try: tfile=self._tfile dlen=tfile.tell() if not dlen: return file=self._file write=file.write tfile.seek(0) id=self._serial user, desc, ext = sel... | def _begin(self, tid, u, d, e): self._thl=23+len(u)+len(d)+len(e) | |
tfile=self._tfile dlen=tfile.tell() if not dlen: return | def _finish(self, tid, u, d, e): tfile=self._tfile dlen=tfile.tell() if not dlen: return # No data in this trans file=self._file write=file.write tfile.seek(0) id=self._serial user, desc, ext = self._ude | |
write=file.write 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) try: write(pack( ">8s" "8s" "c" "H" "H" "H" ,id, stl, 'c', len(user), len(desc), len(ext), )) if user: write(user) if desc: write(desc) if ext: write(ext) ... | file.seek(self._pos+16) file.write(self._tstatus) file.flush() if fsync is not None: fsync(file.fileno()) self._pos=self._nextpos | def _finish(self, tid, u, d, e): tfile=self._tfile dlen=tfile.tell() if not dlen: return # No data in this trans file=self._file write=file.write tfile.seek(0) id=self._serial user, desc, ext = self._ude |
tid, tpos = transaction_id[:8], u64(transaction_id[8:]) | tid, tpos = transaction_id[:8], U64(transaction_id[8:]) | def undo(self, transaction_id): self._lock_acquire() try: self._clear_index() 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 main... |
tl=u64(h[8:16]) | tl=U64(h[8:16]) | def undo(self, transaction_id): self._lock_acquire() try: self._clear_index() 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 main... |
pos=tpos+23+ul+dl+el | pos=tpos+(23+ul+dl+el) | def undo(self, transaction_id): self._lock_acquire() try: self._clear_index() 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 main... |
plen=u64(splen) prev=u64(sprev) | plen=U64(splen) prev=U64(sprev) | def undo(self, transaction_id): self._lock_acquire() try: self._clear_index() 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 main... |
if vlen: dlen=dlen+16+vlen | if vlen: dlen=dlen+(16+vlen) | def undo(self, transaction_id): self._lock_acquire() try: self._clear_index() 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 main... |
pos=pos-u64(read(8))-8 | pos=pos-U64(read(8))-8 | def undoLog(self, first, last, filter=None): self._lock_acquire() try: packt=self._packt if packt is None: raise POSException.UndoError, ( 'Undo is currently disabled for database maintenance.<p>') pos=self._pos if pos < 39: return [] file=self._file seek=file.seek read=file.read unpack=struct.unpack strip=string.strip... |
seek(u64(t)+16) | seek(U64(t)+16) | def versionEmpty(self, version): 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) # serial, prev(oid), tloc, vlen, plen, pnv, pv tloc=h[16:24] if ... |
srcpos=u64(spos) | srcpos=U64(spos) | def versionEmpty(self, version): 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) # serial, prev(oid), tloc, vlen, plen, pnv, pv tloc=h[16:24] if ... |
prev=u64(prev) | prev=U64(prev) | def history(self, oid, version=None, length=1, filter=None): self._lock_acquire() try: r=[] file=self._file seek=file.seek read=file.read pos=self._index[oid] wantver=version |
seek(u64(tloc)) | seek(U64(tloc)) | def history(self, oid, version=None, length=1, filter=None): self._lock_acquire() try: r=[] file=self._file seek=file.seek read=file.read pos=self._index[oid] wantver=version |
if el < 0: el=t32-el | def history(self, oid, version=None, length=1, filter=None): self._lock_acquire() try: r=[] file=self._file seek=file.seek read=file.read pos=self._index[oid] wantver=version | |
d['size']=u64(plen) | d['size']=U64(plen) | def history(self, oid, version=None, length=1, filter=None): self._lock_acquire() try: r=[] file=self._file seek=file.seek read=file.read pos=self._index[oid] wantver=version |
p=u64(file.read(8)) | p=U64(file.read(8)) | def _redundant_pack(self, file, pos): file.seek(pos-8) p=u64(file.read(8)) file.seek(pos-p+8) return file.read(1) not in ' u' |
offset=0 pos=opos=4 | offset=0L pos=opos=4L | 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, sinc... |
if el < 0: el=t32-el tl=u64(stl) | tl=U64(stl) | 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, sinc... |
plen=u64(splen) | plen=U64(splen) | 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, sinc... |
dlen=dlen+16+vlen | dlen=dlen+(16+vlen) | 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, sinc... |
pnv=u64(read(8)) | pnv=U64(read(8)) | 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, sinc... |
p=u64(p) | p=U64(p) | 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, sinc... |
if el < 0: el=t32-el tl=u64(stl) | tl=U64(stl) | def shift_transactions_forward(index, vindex, tindex, file, pos, opos): """Copy transactions forward in the data file This might be done as part of a recovery effort """ # Cache a bunch of methods seek=file.seek read=file.read write=file.write tappend=tindex.append index_get=index.get vindex_get=vindex.get # Initia... |
plen=u64(splen) | plen=U64(splen) | def shift_transactions_forward(index, vindex, tindex, file, pos, opos): """Copy transactions forward in the data file This might be done as part of a recovery effort """ # Cache a bunch of methods seek=file.seek read=file.read write=file.write tappend=tindex.append index_get=index.get vindex_get=vindex.get # Initia... |
dlen=dlen+16+vlen pnv=u64(read(8)) | dlen=dlen+(16+vlen) pnv=U64(read(8)) | def shift_transactions_forward(index, vindex, tindex, file, pos, opos): """Copy transactions forward in the data file This might be done as part of a recovery effort """ # Cache a bunch of methods seek=file.seek read=file.read write=file.write tappend=tindex.append index_get=index.get vindex_get=vindex.get # Initia... |
p=u64(p) | p=U64(p) | def shift_transactions_forward(index, vindex, tindex, file, pos, opos): """Copy transactions forward in the data file This might be done as part of a recovery effort """ # Cache a bunch of methods seek=file.seek read=file.read write=file.write tappend=tindex.append index_get=index.get vindex_get=vindex.get # Initia... |
l=u64(read(8)) | l=U64(read(8)) | def search_back(file, pos): seek=file.seek read=file.read seek(0,2) s=p=file.tell() while p > pos: seek(p-8) l=u64(read(8)) if l <= 0: break p=p-l-8 return p, s |
ltid=z64, start=4, maxoid=z64, recover=0): | ltid=z64, start=4L, maxoid=z64, recover=0): | def read_index(file, name, index, vindex, tindex, stop='\377'*8, ltid=z64, start=4, maxoid=z64, recover=0): read=file.read seek=file.seek seek(0,2) file_size=file.tell() if file_size: if file_size < start: raise FileStorageFormatError, file.name seek(0) if read(4) != packed_version: raise FileStorageFormatError, name... |
return 4, maxoid, ltid | return 4L, maxoid, ltid | def read_index(file, name, index, vindex, tindex, stop='\377'*8, ltid=z64, start=4, maxoid=z64, recover=0): read=file.read seek=file.seek seek(0,2) file_size=file.tell() if file_size: if file_size < start: raise FileStorageFormatError, file.name seek(0) if read(4) != packed_version: raise FileStorageFormatError, name... |
tpos=0 | def read_index(file, name, index, vindex, tindex, stop='\377'*8, ltid=z64, start=4, maxoid=z64, recover=0): read=file.read seek=file.seek seek(0,2) file_size=file.tell() if file_size: if file_size < start: raise FileStorageFormatError, file.name seek(0) if read(4) != packed_version: raise FileStorageFormatError, name... | |
tl=u64(stl) if tl+pos+8 > file_size or status=='c': | tl=U64(stl) if pos+(tl+8) > file_size or status=='c': | def read_index(file, name, index, vindex, tindex, stop='\377'*8, ltid=z64, start=4, maxoid=z64, recover=0): read=file.read seek=file.seek seek(0,2) file_size=file.tell() if file_size: if file_size < start: raise FileStorageFormatError, file.name seek(0) if read(4) != packed_version: raise FileStorageFormatError, name... |
rtl=u64(read(8)) | rtl=U64(read(8)) | def read_index(file, name, index, vindex, tindex, stop='\377'*8, ltid=z64, start=4, maxoid=z64, recover=0): read=file.read seek=file.seek seek(0,2) file_size=file.tell() if file_size: if file_size < start: raise FileStorageFormatError, file.name seek(0) if read(4) != packed_version: raise FileStorageFormatError, name... |
if recover: return tpos, None, None | if recover: return pos, None, None | def read_index(file, name, index, vindex, tindex, stop='\377'*8, ltid=z64, start=4, maxoid=z64, recover=0): read=file.read seek=file.seek seek(0,2) file_size=file.tell() if file_size: if file_size < start: raise FileStorageFormatError, file.name seek(0) if read(4) != packed_version: raise FileStorageFormatError, name... |
pos=tpos+23+ul+dl+el | pos=tpos+(23+ul+dl+el) | def read_index(file, name, index, vindex, tindex, stop='\377'*8, ltid=z64, start=4, maxoid=z64, recover=0): read=file.read seek=file.seek seek(0,2) file_size=file.tell() if file_size: if file_size < start: raise FileStorageFormatError, file.name seek(0) if read(4) != packed_version: raise FileStorageFormatError, name... |
prev=u64(sprev) tloc=u64(stloc) plen=u64(splen) | prev=U64(sprev) tloc=U64(stloc) plen=U64(splen) | def read_index(file, name, index, vindex, tindex, stop='\377'*8, ltid=z64, start=4, maxoid=z64, recover=0): read=file.read seek=file.seek seek(0,2) file_size=file.tell() if file_size: if file_size < start: raise FileStorageFormatError, file.name seek(0) if read(4) != packed_version: raise FileStorageFormatError, name... |
dlen=dlen+16+vlen | dlen=dlen+(16+vlen) | def read_index(file, name, index, vindex, tindex, stop='\377'*8, ltid=z64, start=4, maxoid=z64, recover=0): read=file.read seek=file.seek seek(0,2) file_size=file.tell() if file_size: if file_size < start: raise FileStorageFormatError, file.name seek(0) if read(4) != packed_version: raise FileStorageFormatError, name... |
pv=u64(read(8)) | pv=U64(read(8)) | def read_index(file, name, index, vindex, tindex, stop='\377'*8, ltid=z64, start=4, maxoid=z64, recover=0): read=file.read seek=file.seek seek(0,2) file_size=file.tell() if file_size: if file_size < start: raise FileStorageFormatError, file.name seek(0) if read(4) != packed_version: raise FileStorageFormatError, name... |
old=u64(back) | old=U64(back) | 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 vlen: seek(vlen+16,1) if plen != z64: return read(u64(plen)), serial back=read(8) # We got a back pointer! |
if plen != z64: return read(u64(plen)), serial | if plen != z64: return read(U64(plen)), serial | 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 vlen: seek(vlen+16,1) if plen != z64: return read(u64(plen)), serial back=read(8) # We got a back pointer! |
old=u64(back) | old=U64(back) | def _loadBackPOS(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 vlen: seek(vlen+16,1) if plen != z64: return old back=read(8) # We got a back pointer! |
self._pos=4 | self._pos=4L | def __init__(self, file): if type(file) is type(''): file=open(file, 'r+b') self._file=file if file.read(4) != packed_version: raise FileStorageFormatError, name file.seek(0,2) self._file_size=file.tell() self._pos=4 |
tl=u64(stl) if tl+pos+8 > self._file_size or status=='c': | tl=U64(stl) if pos+(tl+8) > self._file_size or status=='c': | def next(self, index=0): file=self._file seek=file.seek read=file.read pos=self._pos |
rtl=u64(read(8)) | rtl=U64(read(8)) | def next(self, index=0): file=self._file seek=file.seek read=file.read pos=self._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." | 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." | def next(self, index=0): file=self._file seek=file.seek read=file.read pos=self._pos |
pos=tpos+23+ul+dl+el | pos=tpos+(23+ul+dl+el) | def next(self, index=0): file=self._file seek=file.seek read=file.read pos=self._pos |
prev=u64(sprev) tloc=u64(stloc) plen=u64(splen) | prev=U64(sprev) tloc=U64(stloc) plen=U64(splen) | def next(self, index=0): name='' pos = self._pos tend, file, seek, read, tpos = self._stuff while pos < tend: # Read the data records for this transaction |
dlen=dlen+16+vlen | dlen=dlen+(16+vlen) | def next(self, index=0): name='' pos = self._pos tend, file, seek, read, tpos = self._stuff while pos < tend: # Read the data records for this transaction |
pv=u64(read(8)) | pv=U64(read(8)) | def next(self, index=0): name='' pos = self._pos tend, file, seek, read, tpos = self._stuff while pos < tend: # Read the data records for this transaction |
log("wait() async=%d" % self.is_async(), level=zLOG.TRACE) | log("wait(%d), async=%d" % (msgid, self.is_async()), level=zLOG.TRACE) | def wait(self, msgid): """Invoke asyncore mainloop and wait for reply.""" if __debug__: log("wait() async=%d" % self.is_async(), level=zLOG.TRACE) if self.is_async(): self.trigger.pull_trigger() |
asyncore.poll(10.0, self._map) | if __debug__: log("wait(%d): asyncore.poll(%s)" % (msgid, delay), level=zLOG.TRACE) asyncore.poll(delay, self._map) if delay < 1.0: delay += delay | def wait(self, msgid): """Invoke asyncore mainloop and wait for reply.""" if __debug__: log("wait() async=%d" % self.is_async(), level=zLOG.TRACE) if self.is_async(): self.trigger.pull_trigger() |
def testItemsNegativeIndex(self): L = [-3, 6, -11, 4] for i in L: self.t[i] = i L.sort() items = self.t.items() for i in range(-1, -4, -1): self.assertEqual(items[i], (L[i], L[i])) self.assertRaises(IndexError, lambda: items[-5]) | def testItemsWorks(self): for x in range(100): self.t[x] = 2*x v = self.t.items() i = 0 for x in v: self.assertEqual(x[0], i) self.assertEqual(x[1], 2*i) i += 1 | |
zLOG.LOG(label or _label, level, message, error=error) | label = label or _label if LOG_THREAD_ID: label = "%s:%s" % (label, threading.currentThread().getName()) zLOG.LOG(label, level, message, error=error) | def log(message, level=zLOG.BLATHER, label=None, error=None): zLOG.LOG(label or _label, level, message, error=error) |
return | def checkSize(self): # XXX need to fix return self.assertEqual(self.db.cacheSize(), 0) self.assertEqual(self.db.cacheDetailSize(), []) | |
self.assertEquals(self.db.cacheSize(), CACHE_SIZE * CONNS) details = self.db.cacheDetailSize() self.assertEquals(len(details), CONNS) for d in details: self.assertEquals(d['ngsize'], CACHE_SIZE) self.assertEquals(d['size'], CACHE_SIZE + 1) | self.assertEquals(self.db.cacheSize(), 0) | def checkSize(self): # XXX need to fix return self.assertEqual(self.db.cacheSize(), 0) self.assertEqual(self.db.cacheDetailSize(), []) |
return | def checkDetail(self): # XXX need to fix return CACHE_SIZE = 10 self.db.setCacheSize(CACHE_SIZE) | |
for klass, count in self.db.cacheDetail(): print klass, count if klass.endswith('MinPO'): self.assertEqual(count, CONNS * CACHE_SIZE) if klass.endswith('PersistentMapping'): self.assertEqual(count, CONNS) | [(klass, count)] = self.db.cacheDetail() self.assertEqual(klass, "Persistence.PersistentMapping") self.assertEqual(count, CONNS) | def checkDetail(self): # XXX need to fix return CACHE_SIZE = 10 self.db.setCacheSize(CACHE_SIZE) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.