rem
stringlengths 1
322k
| add
stringlengths 0
2.05M
| context
stringlengths 4
228k
| meta
stringlengths 156
215
|
---|---|---|---|
if h < 0: h=t32-h
|
if h < 0: h=t32+h
|
def u64(v, unpack=struct.unpack): h, v = unpack(">ii", v) if v < 0: v=t32-v if h: if h < 0: h=t32-h v=h*t32+v return v
|
28ab567c0c7426ce62c85a6ba9a3cae2bc71a843 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/28ab567c0c7426ce62c85a6ba9a3cae2bc71a843/utils.py
|
if v < t32: h=0
|
if v < t32: h = 0
|
def p64(v, pack=struct.pack): """Pack an integer or long into a 8-byte string""" if v < t32: h=0 else: h=v/t32 v=v%t32 return pack(">II", h, v)
|
d7e74949b1ea5d1b8435e08bdeb37dc29469660d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/d7e74949b1ea5d1b8435e08bdeb37dc29469660d/utils.py
|
h=v/t32 v=v%t32
|
h, v = divmod(v, t32)
|
def p64(v, pack=struct.pack): """Pack an integer or long into a 8-byte string""" if v < t32: h=0 else: h=v/t32 v=v%t32 return pack(">II", h, v)
|
d7e74949b1ea5d1b8435e08bdeb37dc29469660d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/d7e74949b1ea5d1b8435e08bdeb37dc29469660d/utils.py
|
if v < 0: v=t32+v
|
if v < 0: v = t32 + v
|
def u64(v, unpack=struct.unpack): """Unpack an 8-byte string into a 64-bit (or long) integer""" h, v = unpack(">ii", v) if v < 0: v=t32+v if h: if h < 0: h=t32+h v=h*t32+v return v
|
d7e74949b1ea5d1b8435e08bdeb37dc29469660d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/d7e74949b1ea5d1b8435e08bdeb37dc29469660d/utils.py
|
if h < 0: h=t32+h v=h*t32+v
|
if h < 0: h = t32 + h v = (h << 32) + v
|
def u64(v, unpack=struct.unpack): """Unpack an 8-byte string into a 64-bit (or long) integer""" h, v = unpack(">ii", v) if v < 0: v=t32+v if h: if h < 0: h=t32+h v=h*t32+v return v
|
d7e74949b1ea5d1b8435e08bdeb37dc29469660d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/d7e74949b1ea5d1b8435e08bdeb37dc29469660d/utils.py
|
v=h*t32+v
|
v = (h << 32) + v
|
def U64(v, unpack=struct.unpack): """Same as u64 but always returns a long.""" h, v = unpack(">II", v) if h: v=h*t32+v return v
|
d7e74949b1ea5d1b8435e08bdeb37dc29469660d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/d7e74949b1ea5d1b8435e08bdeb37dc29469660d/utils.py
|
def log(msg, level=zLOG.INFO): zLOG.LOG("ZEC", level, msg)
|
def log(msg, level=zLOG.INFO): zLOG.LOG("ZEC", level, msg)
|
18c6f729fe9eb1dc56bff0cb3204d846147e59cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/18c6f729fe9eb1dc56bff0cb3204d846147e59cb/ClientCache.py
|
|
def __init__(self, storage='1', size=20000000, client=None, var=None): # Arguments: # storage -- storage name (used in persistent cache file names only) # size -- size limit in bytes of both files together # client -- if not None, use a persistent cache file and use this name # var -- directory where to create persistent cache files
|
18c6f729fe9eb1dc56bff0cb3204d846147e59cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/18c6f729fe9eb1dc56bff0cb3204d846147e59cb/ClientCache.py
|
||
log("%s: storage=%r, size=%r; file[%r]=%r" % (self.__class__.__name__, storage, size, current, p[current])) self._limit = size / 2
|
self.log("%s: storage=%r, size=%r; file[%r]=%r" % (self.__class__.__name__, storage, size, current, p[current]))
|
def __init__(self, storage='1', size=20000000, client=None, var=None): # Arguments: # storage -- storage name (used in persistent cache file names only) # size -- size limit in bytes of both files together # client -- if not None, use a persistent cache file and use this name # var -- directory where to create persistent cache files
|
18c6f729fe9eb1dc56bff0cb3204d846147e59cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/18c6f729fe9eb1dc56bff0cb3204d846147e59cb/ClientCache.py
|
read_index(index, serial, f[not current], not current) self._pos = read_index(index, serial, f[current], current)
|
self.read_index(serial, not current) self._pos = self.read_index(serial, current)
|
def open(self): # Two tasks: # - Set self._index, self._get, and self._pos. # - Read and validate both cache files, returning a list of # serials to be used by verify(). # This may be called more than once (by the cache verification code). self._acquire() try: self._index = index = {} self._get = index.get serial = {} f = self._f current = self._current if f[not current] is not None: read_index(index, serial, f[not current], not current) self._pos = read_index(index, serial, f[current], current)
|
18c6f729fe9eb1dc56bff0cb3204d846147e59cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/18c6f729fe9eb1dc56bff0cb3204d846147e59cb/ClientCache.py
|
log("invalidate: short record for oid %16x " "at position %d in cache file %d" % (U64(oid), ap, p < 0))
|
self.log("invalidate: short record for oid %16x " "at position %d in cache file %d" % (U64(oid), ap, p < 0))
|
def invalidate(self, oid, version): self._acquire() try: p = self._get(oid, None) if p is None: self._trace(0x10, oid, version) return None f = self._f[p < 0] ap = abs(p) f.seek(ap) h = f.read(27) if len(h) != 27: log("invalidate: short record for oid %16x " "at position %d in cache file %d" % (U64(oid), ap, p < 0)) del self._index[oid] return None if h[:8] != oid: log("invalidate: oid mismatch: expected %16x read %16x " "at position %d in cache file %d" % (U64(oid), U64(h[:8]), ap, p < 0)) del self._index[oid] return None f.seek(ap+8) # Switch from reading to writing if version and h[15:19] != '\0\0\0\0': self._trace(0x1A, oid, version) # There's still relevant non-version data in the cache record f.write('n') else: self._trace(0x1C, oid, version) del self._index[oid] f.write('i') finally: self._release()
|
18c6f729fe9eb1dc56bff0cb3204d846147e59cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/18c6f729fe9eb1dc56bff0cb3204d846147e59cb/ClientCache.py
|
log("invalidate: oid mismatch: expected %16x read %16x " "at position %d in cache file %d" % (U64(oid), U64(h[:8]), ap, p < 0))
|
self.log("invalidate: oid mismatch: expected %16x read %16x " "at position %d in cache file %d" % (U64(oid), U64(h[:8]), ap, p < 0))
|
def invalidate(self, oid, version): self._acquire() try: p = self._get(oid, None) if p is None: self._trace(0x10, oid, version) return None f = self._f[p < 0] ap = abs(p) f.seek(ap) h = f.read(27) if len(h) != 27: log("invalidate: short record for oid %16x " "at position %d in cache file %d" % (U64(oid), ap, p < 0)) del self._index[oid] return None if h[:8] != oid: log("invalidate: oid mismatch: expected %16x read %16x " "at position %d in cache file %d" % (U64(oid), U64(h[:8]), ap, p < 0)) del self._index[oid] return None f.seek(ap+8) # Switch from reading to writing if version and h[15:19] != '\0\0\0\0': self._trace(0x1A, oid, version) # There's still relevant non-version data in the cache record f.write('n') else: self._trace(0x1C, oid, version) del self._index[oid] f.write('i') finally: self._release()
|
18c6f729fe9eb1dc56bff0cb3204d846147e59cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/18c6f729fe9eb1dc56bff0cb3204d846147e59cb/ClientCache.py
|
log("load: bad record for oid %16x " "at position %d in cache file %d" % (U64(oid), ap, p < 0))
|
self.log("load: bad record for oid %16x " "at position %d in cache file %d" % (U64(oid), ap, p < 0))
|
def load(self, oid, version): self._acquire() try: p = self._get(oid, None) if p is None: self._trace(0x20, oid, version) return None f = self._f[p < 0] ap = abs(p) seek = f.seek read = f.read seek(ap) h = read(27) if len(h)==27 and h[8] in 'nv' and h[:8]==oid: tlen, vlen, dlen = unpack(">iHi", h[9:19]) else: tlen = -1 if tlen <= 0 or vlen < 0 or dlen < 0 or vlen+dlen > tlen: log("load: bad record for oid %16x " "at position %d in cache file %d" % (U64(oid), ap, p < 0)) del self._index[oid] return None
|
18c6f729fe9eb1dc56bff0cb3204d846147e59cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/18c6f729fe9eb1dc56bff0cb3204d846147e59cb/ClientCache.py
|
log("modifiedInVersion: bad record for oid %16x " "at position %d in cache file %d" % (U64(oid), ap, p < 0))
|
self.log("modifiedInVersion: bad record for oid %16x " "at position %d in cache file %d" % (U64(oid), ap, p < 0))
|
def modifiedInVersion(self, oid): # This should return: # - The version from the record for oid, if there is one. # - '', if there is no version in the record and its status is 'v'. # - None, if we don't know: no valid record or status is 'n'. self._acquire() try: p = self._get(oid, None) if p is None: self._trace(0x40, oid) return None f = self._f[p < 0] ap = abs(p) seek = f.seek read = f.read seek(ap) h = read(27) if len(h)==27 and h[8] in 'nv' and h[:8]==oid: tlen, vlen, dlen = unpack(">iHi", h[9:19]) else: tlen = -1 if tlen <= 0 or vlen < 0 or dlen < 0 or vlen+dlen > tlen: log("modifiedInVersion: bad record for oid %16x " "at position %d in cache file %d" % (U64(oid), ap, p < 0)) del self._index[oid] return None
|
18c6f729fe9eb1dc56bff0cb3204d846147e59cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/18c6f729fe9eb1dc56bff0cb3204d846147e59cb/ClientCache.py
|
log("flipping cache files. new current = %d" % current)
|
self.log("flipping cache files. new current = %d" % current)
|
def checkSize(self, size): # Make sure we aren't going to exceed the target size. # If we are, then flip the cache. self._acquire() try: if self._pos + size > self._limit: current = not self._current self._current = current self._trace(0x70) log("flipping cache files. new current = %d" % current) # Delete the half of the index that's no longer valid index = self._index for oid in index.keys(): if (index[oid] < 0) == current: del index[oid] if self._p[current] is not None: # Persistent cache file: remove the old file # before opening the new one, because the old file # may be owned by root (created before setuid()). if self._f[current] is not None: self._f[current].close() try: os.remove(self._p[current]) except: pass self._f[current] = open(self._p[current],'w+b') else: # Temporary cache file: self._f[current] = tempfile.TemporaryFile(suffix='.zec') self._f[current].write(magic) self._pos = 4 finally: self._release()
|
18c6f729fe9eb1dc56bff0cb3204d846147e59cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/18c6f729fe9eb1dc56bff0cb3204d846147e59cb/ClientCache.py
|
log("cannot write tracefile %s (%s)" % (tfn, msg)) else: log("opened tracefile %s" % tfn)
|
self.log("cannot write tracefile %s (%s)" % (tfn, msg)) else: self.log("opened tracefile %s" % tfn)
|
def _setup_trace(self): # See if cache tracing is requested through $ZEO_CACHE_TRACE. # If not, or if we can't write to the trace file, # disable tracing by setting self._trace to a dummy function. self._tracefile = None tfn = os.environ.get("ZEO_CACHE_TRACE") if tfn: try: self._tracefile = open(tfn, "ab") self._trace(0x00) except IOError, msg: self._tracefile = None log("cannot write tracefile %s (%s)" % (tfn, msg)) else: log("opened tracefile %s" % tfn) if self._tracefile is None: def notrace(*args): pass self._trace = notrace
|
18c6f729fe9eb1dc56bff0cb3204d846147e59cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/18c6f729fe9eb1dc56bff0cb3204d846147e59cb/ClientCache.py
|
def read_index(index, serial, f, fileindex): seek = f.seek read = f.read pos = 4 count = 0 while 1:
|
def read_index(self, serial, fileindex): index = self._index f = self._f[fileindex] seek = f.seek read = f.read pos = 4 count = 0 while 1: f.seek(pos) h = read(27) if len(h) != 27: if h: self.rilog("truncated header", pos, fileindex) break if h[8] in 'vni': tlen, vlen, dlen = unpack(">iHi", h[9:19]) else: tlen = -1 if tlen <= 0 or vlen < 0 or dlen < 0 or vlen + dlen > tlen: self.rilog("invalid header data", pos, fileindex) break oid = h[:8] if h[8] == 'v' and vlen: seek(dlen+vlen, 1) vdlen = read(4) if len(vdlen) != 4: self.rilog("truncated record", pos, fileindex) break vdlen = unpack(">i", vdlen)[0] if vlen+dlen+43+vdlen != tlen: self.rilog("inconsistent lengths", pos, fileindex) break seek(vdlen, 1) vs = read(8) if read(4) != h[9:13]: self.rilog("inconsistent tlen", pos, fileindex) break else: if h[8] in 'vn' and vlen == 0: if dlen+31 != tlen: self.rilog("inconsistent nv lengths", pos, fileindex) seek(dlen, 1) if read(4) != h[9:13]: self.rilog("inconsistent nv tlen", pos, fileindex) break vs = None if h[8] in 'vn': if fileindex: index[oid] = -pos else: index[oid] = pos serial[oid] = h[-8:], vs else: if serial.has_key(oid): del serial[oid] del index[oid] pos = pos + tlen count += 1
|
def read_index(index, serial, f, fileindex): seek = f.seek read = f.read pos = 4 count = 0 while 1: f.seek(pos) h = read(27) if len(h) != 27: # An empty read is expected, anything else is suspect if h: rilog("truncated header", pos, fileindex) break if h[8] in 'vni': tlen, vlen, dlen = unpack(">iHi", h[9:19]) else: tlen = -1 if tlen <= 0 or vlen < 0 or dlen < 0 or vlen + dlen > tlen: rilog("invalid header data", pos, fileindex) break oid = h[:8] if h[8] == 'v' and vlen: seek(dlen+vlen, 1) vdlen = read(4) if len(vdlen) != 4: rilog("truncated record", pos, fileindex) break vdlen = unpack(">i", vdlen)[0] if vlen+dlen+43+vdlen != tlen: rilog("inconsistent lengths", pos, fileindex) break seek(vdlen, 1) vs = read(8) if read(4) != h[9:13]: rilog("inconsistent tlen", pos, fileindex) break else: if h[8] in 'vn' and vlen == 0: if dlen+31 != tlen: rilog("inconsistent nv lengths", pos, fileindex) seek(dlen, 1) if read(4) != h[9:13]: rilog("inconsistent nv tlen", pos, fileindex) break vs = None if h[8] in 'vn': if fileindex: index[oid] = -pos else: index[oid] = pos serial[oid] = h[-8:], vs else: if serial.has_key(oid): # We have a record for this oid, but it was invalidated! del serial[oid] del index[oid] pos = pos + tlen count += 1 f.seek(pos) try: f.truncate() except: pass if count: log("read_index: cache file %d has %d records and %d bytes" % (fileindex, count, pos)) return pos
|
18c6f729fe9eb1dc56bff0cb3204d846147e59cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/18c6f729fe9eb1dc56bff0cb3204d846147e59cb/ClientCache.py
|
h = read(27) if len(h) != 27: if h: rilog("truncated header", pos, fileindex) break if h[8] in 'vni': tlen, vlen, dlen = unpack(">iHi", h[9:19]) else: tlen = -1 if tlen <= 0 or vlen < 0 or dlen < 0 or vlen + dlen > tlen: rilog("invalid header data", pos, fileindex) break oid = h[:8] if h[8] == 'v' and vlen: seek(dlen+vlen, 1) vdlen = read(4) if len(vdlen) != 4: rilog("truncated record", pos, fileindex) break vdlen = unpack(">i", vdlen)[0] if vlen+dlen+43+vdlen != tlen: rilog("inconsistent lengths", pos, fileindex) break seek(vdlen, 1) vs = read(8) if read(4) != h[9:13]: rilog("inconsistent tlen", pos, fileindex) break else: if h[8] in 'vn' and vlen == 0: if dlen+31 != tlen: rilog("inconsistent nv lengths", pos, fileindex) seek(dlen, 1) if read(4) != h[9:13]: rilog("inconsistent nv tlen", pos, fileindex) break vs = None if h[8] in 'vn': if fileindex: index[oid] = -pos else: index[oid] = pos serial[oid] = h[-8:], vs else: if serial.has_key(oid): del serial[oid] del index[oid] pos = pos + tlen count += 1 f.seek(pos) try: f.truncate() except: pass if count: log("read_index: cache file %d has %d records and %d bytes" % (fileindex, count, pos)) return pos def rilog(msg, pos, fileindex): log("read_index: %s at position %d in cache file %d" % (msg, pos, fileindex))
|
try: f.truncate() except: pass if count: self.log("read_index: cache file %d has %d records and %d bytes" % (fileindex, count, pos)) return pos def rilog(self, msg, pos, fileindex): self.log("read_index: %s at position %d in cache file %d" % (msg, pos, fileindex)) def log(self, msg, level=zLOG.INFO): zLOG.LOG("ZEC:%s" % self._storage, level, msg)
|
def read_index(index, serial, f, fileindex): seek = f.seek read = f.read pos = 4 count = 0 while 1: f.seek(pos) h = read(27) if len(h) != 27: # An empty read is expected, anything else is suspect if h: rilog("truncated header", pos, fileindex) break if h[8] in 'vni': tlen, vlen, dlen = unpack(">iHi", h[9:19]) else: tlen = -1 if tlen <= 0 or vlen < 0 or dlen < 0 or vlen + dlen > tlen: rilog("invalid header data", pos, fileindex) break oid = h[:8] if h[8] == 'v' and vlen: seek(dlen+vlen, 1) vdlen = read(4) if len(vdlen) != 4: rilog("truncated record", pos, fileindex) break vdlen = unpack(">i", vdlen)[0] if vlen+dlen+43+vdlen != tlen: rilog("inconsistent lengths", pos, fileindex) break seek(vdlen, 1) vs = read(8) if read(4) != h[9:13]: rilog("inconsistent tlen", pos, fileindex) break else: if h[8] in 'vn' and vlen == 0: if dlen+31 != tlen: rilog("inconsistent nv lengths", pos, fileindex) seek(dlen, 1) if read(4) != h[9:13]: rilog("inconsistent nv tlen", pos, fileindex) break vs = None if h[8] in 'vn': if fileindex: index[oid] = -pos else: index[oid] = pos serial[oid] = h[-8:], vs else: if serial.has_key(oid): # We have a record for this oid, but it was invalidated! del serial[oid] del index[oid] pos = pos + tlen count += 1 f.seek(pos) try: f.truncate() except: pass if count: log("read_index: cache file %d has %d records and %d bytes" % (fileindex, count, pos)) return pos
|
18c6f729fe9eb1dc56bff0cb3204d846147e59cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/18c6f729fe9eb1dc56bff0cb3204d846147e59cb/ClientCache.py
|
cs = ClientStorage(addr, storage=storage, debug=1, wait=1)
|
cs = ClientStorage(addr, storage=storage, wait=1, read_only=1)
|
def check_server(addr, storage, write): if ZEO_VERSION == 2: cs = ClientStorage(addr, storage=storage, debug=1, wait=1) else: cs = ClientStorage(addr, storage=storage, debug=1, wait_for_server_on_startup=1) # _startup() is an artifact of the way ZEO 1.0 works. The # ClientStorage doesn't get fully initialized until registerDB() # is called. The only thing we care about, though, is that # registerDB() calls _startup(). db = ZODB.DB(cs) cn = db.open() root = cn.root() if write: try: root['zeoup'] = root.get('zeoup', 0)+ 1 get_transaction().commit() except ConflictError: pass cn.close() db.close()
|
556a793f6d1fc764ba57c27042ccefb189c0225d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/556a793f6d1fc764ba57c27042ccefb189c0225d/zeoup.py
|
def testEmptyFirstBucketReportedByGuido(self):
|
def XXXtestEmptyFirstBucketReportedByGuido(self):
|
def testEmptyFirstBucketReportedByGuido(self): b = self.t for i in xrange(29972): # reduce to 29971 and it works b[i] = i for i in xrange(30): # reduce to 29 and it works del b[i] b[i+40000] = i
|
d27d3a6d0225a9361dffce8a5a6d8c151389b287 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/d27d3a6d0225a9361dffce8a5a6d8c151389b287/testBTrees.py
|
if not self._oids: self._oids = self._server.new_oids() self._oids.reverse() oid = self._oids.pop() self._oid_lock.release() return oid
|
try: if not self._oids: self._oids = self._server.new_oids() self._oids.reverse() return self._oids.pop() finally: self._oid_lock.release()
|
def new_oid(self, last=None): if self._is_read_only: raise POSException.ReadOnlyError() # avoid multiple oid requests to server at the same time self._oid_lock.acquire() if not self._oids: self._oids = self._server.new_oids() self._oids.reverse() oid = self._oids.pop() self._oid_lock.release() return oid
|
e665b885a307a437fa77dc8ae383c1c0fbf8e88d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e665b885a307a437fa77dc8ae383c1c0fbf8e88d/ClientStorage.py
|
0
|
False
|
def __getattr__(self, name): """Get attributes that can't be gotten the usual way
|
cce3c72e4dd89a22de5db2fcf0875be7431c0fca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/cce3c72e4dd89a22de5db2fcf0875be7431c0fca/test_overriding_attrs.py
|
try: del self._keys
|
try: del self._v_keys
|
def __setitem__(self, key, v):
|
37130a76c083481cb70c3b12bc9f8d849e2452a5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/37130a76c083481cb70c3b12bc9f8d849e2452a5/Persistence.py
|
try: del self._keys
|
try: del self._v_keys
|
def __delitem__(self, key):
|
37130a76c083481cb70c3b12bc9f8d849e2452a5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/37130a76c083481cb70c3b12bc9f8d849e2452a5/Persistence.py
|
try: return self._keys
|
try: return self._v_keys
|
def keys(self):
|
37130a76c083481cb70c3b12bc9f8d849e2452a5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/37130a76c083481cb70c3b12bc9f8d849e2452a5/Persistence.py
|
keys=self._keys=filter(
|
keys=self._v_keys=filter(
|
def keys(self):
|
37130a76c083481cb70c3b12bc9f8d849e2452a5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/37130a76c083481cb70c3b12bc9f8d849e2452a5/Persistence.py
|
if hasattr(self,'_keys'): del self._keys
|
if hasattr(self,'_v_keys'): del self._v_keys
|
def clear(self):
|
37130a76c083481cb70c3b12bc9f8d849e2452a5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/37130a76c083481cb70c3b12bc9f8d849e2452a5/Persistence.py
|
another. `other' must have an .iterator() method.
|
another. `other` must have an .iterator() method.
|
def copyTransactionsFrom(self, other, verbose=0): """Copy transactions from another storage.
|
65df37866a84d3f5048116931d5872c773f2956a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/65df37866a84d3f5048116931d5872c773f2956a/BaseStorage.py
|
opts, args = getopt.getopt(args, 'zd:n:Ds:M')
|
opts, args = getopt.getopt(args, 'zd:n:Ds:L')
|
def main(args): opts, args = getopt.getopt(args, 'zd:n:Ds:M') z=s=None data=sys.argv[0] nrep=5 minimize=0 for o, v in opts: if o=='-n': nrep=string.atoi(v) elif o=='-d': data=v elif o=='-s': s=v elif o=='-z': global zlib import zlib z=compress elif o=='-M': minimize=1 elif o=='-D': global debug os.environ['STUPID_LOG_FILE']='' os.environ['STUPID_LOG_SEVERITY']='-999' __builtins__.__debug__=1 if s: s=__import__(s, globals(), globals(), ('__doc__',)) s=s.Storage else: s=ZODB.FileStorage.FileStorage('zeo_speed.fs', create=1) data=open(data).read() db=ZODB.DB(s, # disable cache deactivation cache_size=4000, cache_deactivate_after=6000,) results={} for j in range(nrep): for r in 1, 10, 100, 1000: t=time.time() jar=db.open() get_transaction().begin() rt=jar.root() key='s%s' % r if rt.has_key(key): p=rt[key] else: rt[key]=p=P() for i in range(r): if z is not None: d=z(data) else: d=data v=getattr(p, str(i), P()) v.d=d setattr(p,str(i),v) get_transaction().commit() jar.close() sys.stderr.write("%s %s %s\n" % (j, r, time.time()-t)) sys.stdout.flush() rt=d=p=v=None # release all references if minimize: time.sleep(3) jar.cacheMinimize(3)
|
f945ce2b2819d3d7fe5d9f284fc13516ed151986 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/f945ce2b2819d3d7fe5d9f284fc13516ed151986/speed.py
|
return '<Connection at %08x%s>' % (id(self),ver)
|
return '<Connection at %08x%s>' % (id(self), ver)
|
def __repr__(self): if self._version: ver = ' (in version %s)' % `self._version` else: ver = '' return '<Connection at %08x%s>' % (id(self),ver)
|
8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9/Connection.py
|
self._cache.invalidate(object._p_oid)
|
if object._p_oid is not None: self._cache.invalidate(object._p_oid)
|
def abort(self, object, transaction): """Abort the object in the transaction.
|
8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9/Connection.py
|
self._invalidated[oid]=1
|
assert oid is not None self._invalidated[oid] = 1
|
def invalidate(self, oid): """Invalidate a particular oid
|
8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9/Connection.py
|
oid=object._p_oid
|
oid = object._p_oid
|
def setstate(self, object): oid=object._p_oid
|
8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9/Connection.py
|
msg = "Shouldn't load state for %s when the connection is closed" % `oid` LOG('ZODB',ERROR, msg)
|
msg = ("Shouldn't load state for %s " "when the connection is closed" % `oid`) LOG('ZODB', ERROR, msg)
|
def setstate(self, object): oid=object._p_oid
|
8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9/Connection.py
|
invalid=self._invalid
|
invalid = self._invalid
|
def setstate(self, object): oid=object._p_oid
|
8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9/Connection.py
|
invalid=1
|
invalid = 1
|
def setstate(self, object): oid=object._p_oid
|
8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9/Connection.py
|
invalid=0 file=StringIO(p) unpickler=Unpickler(file) unpickler.persistent_load=self._persistent_load
|
invalid = 0 file = StringIO(p) unpickler = Unpickler(file) unpickler.persistent_load = self._persistent_load
|
def setstate(self, object): oid=object._p_oid
|
8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9/Connection.py
|
d=object.__dict__ for k,v in state.items(): d[k]=v object._p_serial=serial
|
d = object.__dict__ for k, v in state.items(): d[k] = v object._p_serial = serial
|
def setstate(self, object): oid=object._p_oid
|
8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9/Connection.py
|
try: del self._invalidated[oid] except KeyError: pass
|
try: del self._invalidated[oid] except KeyError: pass
|
def setstate(self, object): oid=object._p_oid
|
8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9/Connection.py
|
def _handle_serial(self, store_return, oid=None, change=1): """Handle the returns from store() and tpc_vote() calls."""
|
8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9/Connection.py
|
||
def tpc_finish(self, transaction):
|
8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9/Connection.py
|
||
invalidate=self._db.invalidate
|
def _invalidate_invalidating(self): invalidate=self._db.invalidate for oid in self._invalidating: invalidate(oid, self) self._db.finish_invalidation()
|
8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9/Connection.py
|
|
invalidate(oid, self)
|
assert oid is not None self._db.invalidate(oid, self)
|
def _invalidate_invalidating(self): invalidate=self._db.invalidate for oid in self._invalidating: invalidate(oid, self) self._db.finish_invalidation()
|
8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9/Connection.py
|
def getDebugInfo(self): return self._debug_info def setDebugInfo(self, *args): self._debug_info=self._debug_info+args
|
def getDebugInfo(self): return self._debug_info def setDebugInfo(self, *args): self._debug_info = self._debug_info + args
|
def getDebugInfo(self): return self._debug_info
|
8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9/Connection.py
|
res = (self._load_count, self._store_count)
|
res = self._load_count, self._store_count
|
def getTransferCounts(self, clear=0): """Returns the number of objects loaded and stored.
|
8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/8f44f0fa4dea8b55bb647630f9a0187d2cf2b3c9/Connection.py
|
def setCacheDeactivateAfter(self, v): self._cache_deactivate_after=v def setCacheSize(self, v): self._cache_size=v
|
def setCacheDeactivateAfter(self, v): self._cache_deactivate_after=v for c in self._pools[0][''][1]: c._cache.cache_age=v def setCacheSize(self, v): self._cache_size=v for c in self._pools[0][''][1]: c._cache.cache_size=v
|
def setCacheDeactivateAfter(self, v): self._cache_deactivate_after=v
|
cce3284db070a268bbc6e5c48cad91734762d81a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/cce3284db070a268bbc6e5c48cad91734762d81a/DB.py
|
def setVersionCacheSize(self, v): self._version_cache_size=v
|
for ver in self._pools[0].keys(): if ver: for c in self._pools[0][ver][1]: c._cache.cache_age=v def setVersionCacheSize(self, v): self._version_cache_size=v for ver in self._pools[0].keys(): if v: for c in self._pools[0][ver][1]: c._cache.cache_size=v
|
def setVersionCacheSize(self, v): self._version_cache_size=v
|
cce3284db070a268bbc6e5c48cad91734762d81a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/cce3284db070a268bbc6e5c48cad91734762d81a/DB.py
|
__traceback_info__=oid
|
__traceback_info__ = (oid, p)
|
def __getitem__(self, oid, tt=type(()), ct=type(HelperClass)): cache=self._cache if cache.has_key(oid): return cache[oid]
|
cefe54e871aa7332bdb312bf50772e1786f2c1fb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/cefe54e871aa7332bdb312bf50772e1786f2c1fb/Connection.py
|
object = unpickler.load()
|
try: object = unpickler.load() except: raise "Could not load oid %s, pickled data in traceback info may\ contain clues" % (oid)
|
def __getitem__(self, oid, tt=type(()), ct=type(HelperClass)): cache=self._cache if cache.has_key(oid): return cache[oid]
|
cefe54e871aa7332bdb312bf50772e1786f2c1fb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/cefe54e871aa7332bdb312bf50772e1786f2c1fb/Connection.py
|
current=not current
|
current=not self._current
|
def checkSize(self, size): # Make sure we aren't going to exceed the target size. # If we are, then flip the cache. if self._pos+size > self._limit: current=not current self._current=current self._f[current]=open(self._p[current],'w+b') self._f[current].write(magic) self._pos=pos=4
|
516b5076fb20745e1661108d649bf82ab5670ecc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/516b5076fb20745e1661108d649bf82ab5670ecc/ClientCache.py
|
unpickler.load() state = unpickler.load()
|
try: unpickler.load() state = unpickler.load() except: t, v =sys.exc_info()[:2] raise
|
def setstate(self,object): # Note, we no longer mess with the object's state # flag, _p_changed. This is the object's job. oid=object._p_oid invalid=self._invalid if invalid(oid) or invalid(None): raise ConflictError, oid p, serial = self._storage.load(oid, self._version) file=StringIO(p) unpickler=Unpickler(file) unpickler.persistent_load=self._persistent_load unpickler.load() state = unpickler.load() if hasattr(object, '__setstate__'): object.__setstate__(state) else: d=object.__dict__ for k,v in state.items(): d[k]=v object._p_serial=serial
|
f6a4756fbb5522e2996db29cc68484b3bd39226f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/f6a4756fbb5522e2996db29cc68484b3bd39226f/Connection.py
|
unless = self.failUnless
|
require = self.assert_
|
def checkTimeoutProvokingConflicts(self): eq = self.assertEqual raises = self.assertRaises unless = self.failUnless self._storage = storage = self.openClientStorage() # Assert that the zeo cache is empty unless(not list(storage._cache.contents())) # Create the object oid = storage.new_oid() obj = MinPO(7) # We need to successfully commit an object now so we have something to # conflict about. t = Transaction() storage.tpc_begin(t) revid1a = storage.store(oid, ZERO, zodb_pickle(obj), '', t) revid1b = storage.tpc_vote(t) revid1 = handle_serials(oid, revid1a, revid1b) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 8 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) # Now sleep long enough for the storage to time out time.sleep(3) storage.sync() unless(not storage.is_connected()) storage._wait() unless(storage.is_connected()) # We expect finish to fail raises(ClientDisconnected, storage.tpc_finish, t) # Now we think we've committed the second transaction, but we really # haven't. A third one should produce a POSKeyError on the server, # which manifests as a ConflictError on the client. obj.value = 9 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) raises(ConflictError, storage.tpc_vote, t) # Even aborting won't help storage.tpc_abort(t) storage.tpc_finish(t) # Try again obj.value = 10 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) # Even aborting won't help raises(ConflictError, storage.tpc_vote, t) # Abort this one and try a transaction that should succeed storage.tpc_abort(t) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 11 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) storage.tpc_finish(t) # Now load the object and verify that it has a value of 11 data, revid = storage.load(oid, '') eq(zodb_unpickle(data), MinPO(11)) eq(revid, revid2)
|
4659d8eb20fb53ceb449f9082c96342b24dfed27 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/4659d8eb20fb53ceb449f9082c96342b24dfed27/ConnectionTests.py
|
unless(not list(storage._cache.contents()))
|
require(not list(storage._cache.contents()))
|
def checkTimeoutProvokingConflicts(self): eq = self.assertEqual raises = self.assertRaises unless = self.failUnless self._storage = storage = self.openClientStorage() # Assert that the zeo cache is empty unless(not list(storage._cache.contents())) # Create the object oid = storage.new_oid() obj = MinPO(7) # We need to successfully commit an object now so we have something to # conflict about. t = Transaction() storage.tpc_begin(t) revid1a = storage.store(oid, ZERO, zodb_pickle(obj), '', t) revid1b = storage.tpc_vote(t) revid1 = handle_serials(oid, revid1a, revid1b) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 8 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) # Now sleep long enough for the storage to time out time.sleep(3) storage.sync() unless(not storage.is_connected()) storage._wait() unless(storage.is_connected()) # We expect finish to fail raises(ClientDisconnected, storage.tpc_finish, t) # Now we think we've committed the second transaction, but we really # haven't. A third one should produce a POSKeyError on the server, # which manifests as a ConflictError on the client. obj.value = 9 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) raises(ConflictError, storage.tpc_vote, t) # Even aborting won't help storage.tpc_abort(t) storage.tpc_finish(t) # Try again obj.value = 10 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) # Even aborting won't help raises(ConflictError, storage.tpc_vote, t) # Abort this one and try a transaction that should succeed storage.tpc_abort(t) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 11 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) storage.tpc_finish(t) # Now load the object and verify that it has a value of 11 data, revid = storage.load(oid, '') eq(zodb_unpickle(data), MinPO(11)) eq(revid, revid2)
|
4659d8eb20fb53ceb449f9082c96342b24dfed27 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/4659d8eb20fb53ceb449f9082c96342b24dfed27/ConnectionTests.py
|
def checkTimeoutProvokingConflicts(self): eq = self.assertEqual raises = self.assertRaises unless = self.failUnless self._storage = storage = self.openClientStorage() # Assert that the zeo cache is empty unless(not list(storage._cache.contents())) # Create the object oid = storage.new_oid() obj = MinPO(7) # We need to successfully commit an object now so we have something to # conflict about. t = Transaction() storage.tpc_begin(t) revid1a = storage.store(oid, ZERO, zodb_pickle(obj), '', t) revid1b = storage.tpc_vote(t) revid1 = handle_serials(oid, revid1a, revid1b) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 8 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) # Now sleep long enough for the storage to time out time.sleep(3) storage.sync() unless(not storage.is_connected()) storage._wait() unless(storage.is_connected()) # We expect finish to fail raises(ClientDisconnected, storage.tpc_finish, t) # Now we think we've committed the second transaction, but we really # haven't. A third one should produce a POSKeyError on the server, # which manifests as a ConflictError on the client. obj.value = 9 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) raises(ConflictError, storage.tpc_vote, t) # Even aborting won't help storage.tpc_abort(t) storage.tpc_finish(t) # Try again obj.value = 10 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) # Even aborting won't help raises(ConflictError, storage.tpc_vote, t) # Abort this one and try a transaction that should succeed storage.tpc_abort(t) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 11 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) storage.tpc_finish(t) # Now load the object and verify that it has a value of 11 data, revid = storage.load(oid, '') eq(zodb_unpickle(data), MinPO(11)) eq(revid, revid2)
|
4659d8eb20fb53ceb449f9082c96342b24dfed27 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/4659d8eb20fb53ceb449f9082c96342b24dfed27/ConnectionTests.py
|
||
time.sleep(3)
|
deadline = time.time() + 60 while time.time() < deadline: if storage.is_connected(): time.sleep(self.timeout / 1.8) storage.sync() else: break
|
def checkTimeoutProvokingConflicts(self): eq = self.assertEqual raises = self.assertRaises unless = self.failUnless self._storage = storage = self.openClientStorage() # Assert that the zeo cache is empty unless(not list(storage._cache.contents())) # Create the object oid = storage.new_oid() obj = MinPO(7) # We need to successfully commit an object now so we have something to # conflict about. t = Transaction() storage.tpc_begin(t) revid1a = storage.store(oid, ZERO, zodb_pickle(obj), '', t) revid1b = storage.tpc_vote(t) revid1 = handle_serials(oid, revid1a, revid1b) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 8 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) # Now sleep long enough for the storage to time out time.sleep(3) storage.sync() unless(not storage.is_connected()) storage._wait() unless(storage.is_connected()) # We expect finish to fail raises(ClientDisconnected, storage.tpc_finish, t) # Now we think we've committed the second transaction, but we really # haven't. A third one should produce a POSKeyError on the server, # which manifests as a ConflictError on the client. obj.value = 9 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) raises(ConflictError, storage.tpc_vote, t) # Even aborting won't help storage.tpc_abort(t) storage.tpc_finish(t) # Try again obj.value = 10 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) # Even aborting won't help raises(ConflictError, storage.tpc_vote, t) # Abort this one and try a transaction that should succeed storage.tpc_abort(t) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 11 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) storage.tpc_finish(t) # Now load the object and verify that it has a value of 11 data, revid = storage.load(oid, '') eq(zodb_unpickle(data), MinPO(11)) eq(revid, revid2)
|
4659d8eb20fb53ceb449f9082c96342b24dfed27 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/4659d8eb20fb53ceb449f9082c96342b24dfed27/ConnectionTests.py
|
unless(not storage.is_connected())
|
require(not storage.is_connected())
|
def checkTimeoutProvokingConflicts(self): eq = self.assertEqual raises = self.assertRaises unless = self.failUnless self._storage = storage = self.openClientStorage() # Assert that the zeo cache is empty unless(not list(storage._cache.contents())) # Create the object oid = storage.new_oid() obj = MinPO(7) # We need to successfully commit an object now so we have something to # conflict about. t = Transaction() storage.tpc_begin(t) revid1a = storage.store(oid, ZERO, zodb_pickle(obj), '', t) revid1b = storage.tpc_vote(t) revid1 = handle_serials(oid, revid1a, revid1b) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 8 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) # Now sleep long enough for the storage to time out time.sleep(3) storage.sync() unless(not storage.is_connected()) storage._wait() unless(storage.is_connected()) # We expect finish to fail raises(ClientDisconnected, storage.tpc_finish, t) # Now we think we've committed the second transaction, but we really # haven't. A third one should produce a POSKeyError on the server, # which manifests as a ConflictError on the client. obj.value = 9 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) raises(ConflictError, storage.tpc_vote, t) # Even aborting won't help storage.tpc_abort(t) storage.tpc_finish(t) # Try again obj.value = 10 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) # Even aborting won't help raises(ConflictError, storage.tpc_vote, t) # Abort this one and try a transaction that should succeed storage.tpc_abort(t) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 11 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) storage.tpc_finish(t) # Now load the object and verify that it has a value of 11 data, revid = storage.load(oid, '') eq(zodb_unpickle(data), MinPO(11)) eq(revid, revid2)
|
4659d8eb20fb53ceb449f9082c96342b24dfed27 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/4659d8eb20fb53ceb449f9082c96342b24dfed27/ConnectionTests.py
|
unless(storage.is_connected())
|
require(storage.is_connected())
|
def checkTimeoutProvokingConflicts(self): eq = self.assertEqual raises = self.assertRaises unless = self.failUnless self._storage = storage = self.openClientStorage() # Assert that the zeo cache is empty unless(not list(storage._cache.contents())) # Create the object oid = storage.new_oid() obj = MinPO(7) # We need to successfully commit an object now so we have something to # conflict about. t = Transaction() storage.tpc_begin(t) revid1a = storage.store(oid, ZERO, zodb_pickle(obj), '', t) revid1b = storage.tpc_vote(t) revid1 = handle_serials(oid, revid1a, revid1b) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 8 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) # Now sleep long enough for the storage to time out time.sleep(3) storage.sync() unless(not storage.is_connected()) storage._wait() unless(storage.is_connected()) # We expect finish to fail raises(ClientDisconnected, storage.tpc_finish, t) # Now we think we've committed the second transaction, but we really # haven't. A third one should produce a POSKeyError on the server, # which manifests as a ConflictError on the client. obj.value = 9 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) raises(ConflictError, storage.tpc_vote, t) # Even aborting won't help storage.tpc_abort(t) storage.tpc_finish(t) # Try again obj.value = 10 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) # Even aborting won't help raises(ConflictError, storage.tpc_vote, t) # Abort this one and try a transaction that should succeed storage.tpc_abort(t) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 11 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) storage.tpc_finish(t) # Now load the object and verify that it has a value of 11 data, revid = storage.load(oid, '') eq(zodb_unpickle(data), MinPO(11)) eq(revid, revid2)
|
4659d8eb20fb53ceb449f9082c96342b24dfed27 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/4659d8eb20fb53ceb449f9082c96342b24dfed27/ConnectionTests.py
|
def checkTimeoutProvokingConflicts(self): eq = self.assertEqual raises = self.assertRaises unless = self.failUnless self._storage = storage = self.openClientStorage() # Assert that the zeo cache is empty unless(not list(storage._cache.contents())) # Create the object oid = storage.new_oid() obj = MinPO(7) # We need to successfully commit an object now so we have something to # conflict about. t = Transaction() storage.tpc_begin(t) revid1a = storage.store(oid, ZERO, zodb_pickle(obj), '', t) revid1b = storage.tpc_vote(t) revid1 = handle_serials(oid, revid1a, revid1b) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 8 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) # Now sleep long enough for the storage to time out time.sleep(3) storage.sync() unless(not storage.is_connected()) storage._wait() unless(storage.is_connected()) # We expect finish to fail raises(ClientDisconnected, storage.tpc_finish, t) # Now we think we've committed the second transaction, but we really # haven't. A third one should produce a POSKeyError on the server, # which manifests as a ConflictError on the client. obj.value = 9 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) raises(ConflictError, storage.tpc_vote, t) # Even aborting won't help storage.tpc_abort(t) storage.tpc_finish(t) # Try again obj.value = 10 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) # Even aborting won't help raises(ConflictError, storage.tpc_vote, t) # Abort this one and try a transaction that should succeed storage.tpc_abort(t) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 11 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) storage.tpc_finish(t) # Now load the object and verify that it has a value of 11 data, revid = storage.load(oid, '') eq(zodb_unpickle(data), MinPO(11)) eq(revid, revid2)
|
4659d8eb20fb53ceb449f9082c96342b24dfed27 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/4659d8eb20fb53ceb449f9082c96342b24dfed27/ConnectionTests.py
|
||
def checkTimeoutProvokingConflicts(self): eq = self.assertEqual raises = self.assertRaises unless = self.failUnless self._storage = storage = self.openClientStorage() # Assert that the zeo cache is empty unless(not list(storage._cache.contents())) # Create the object oid = storage.new_oid() obj = MinPO(7) # We need to successfully commit an object now so we have something to # conflict about. t = Transaction() storage.tpc_begin(t) revid1a = storage.store(oid, ZERO, zodb_pickle(obj), '', t) revid1b = storage.tpc_vote(t) revid1 = handle_serials(oid, revid1a, revid1b) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 8 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) # Now sleep long enough for the storage to time out time.sleep(3) storage.sync() unless(not storage.is_connected()) storage._wait() unless(storage.is_connected()) # We expect finish to fail raises(ClientDisconnected, storage.tpc_finish, t) # Now we think we've committed the second transaction, but we really # haven't. A third one should produce a POSKeyError on the server, # which manifests as a ConflictError on the client. obj.value = 9 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) raises(ConflictError, storage.tpc_vote, t) # Even aborting won't help storage.tpc_abort(t) storage.tpc_finish(t) # Try again obj.value = 10 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) # Even aborting won't help raises(ConflictError, storage.tpc_vote, t) # Abort this one and try a transaction that should succeed storage.tpc_abort(t) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 11 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) storage.tpc_finish(t) # Now load the object and verify that it has a value of 11 data, revid = storage.load(oid, '') eq(zodb_unpickle(data), MinPO(11)) eq(revid, revid2)
|
4659d8eb20fb53ceb449f9082c96342b24dfed27 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/4659d8eb20fb53ceb449f9082c96342b24dfed27/ConnectionTests.py
|
||
def checkTimeoutProvokingConflicts(self): eq = self.assertEqual raises = self.assertRaises unless = self.failUnless self._storage = storage = self.openClientStorage() # Assert that the zeo cache is empty unless(not list(storage._cache.contents())) # Create the object oid = storage.new_oid() obj = MinPO(7) # We need to successfully commit an object now so we have something to # conflict about. t = Transaction() storage.tpc_begin(t) revid1a = storage.store(oid, ZERO, zodb_pickle(obj), '', t) revid1b = storage.tpc_vote(t) revid1 = handle_serials(oid, revid1a, revid1b) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 8 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) # Now sleep long enough for the storage to time out time.sleep(3) storage.sync() unless(not storage.is_connected()) storage._wait() unless(storage.is_connected()) # We expect finish to fail raises(ClientDisconnected, storage.tpc_finish, t) # Now we think we've committed the second transaction, but we really # haven't. A third one should produce a POSKeyError on the server, # which manifests as a ConflictError on the client. obj.value = 9 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) raises(ConflictError, storage.tpc_vote, t) # Even aborting won't help storage.tpc_abort(t) storage.tpc_finish(t) # Try again obj.value = 10 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) # Even aborting won't help raises(ConflictError, storage.tpc_vote, t) # Abort this one and try a transaction that should succeed storage.tpc_abort(t) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 11 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) storage.tpc_finish(t) # Now load the object and verify that it has a value of 11 data, revid = storage.load(oid, '') eq(zodb_unpickle(data), MinPO(11)) eq(revid, revid2)
|
4659d8eb20fb53ceb449f9082c96342b24dfed27 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/4659d8eb20fb53ceb449f9082c96342b24dfed27/ConnectionTests.py
|
||
def checkTimeoutProvokingConflicts(self): eq = self.assertEqual raises = self.assertRaises unless = self.failUnless self._storage = storage = self.openClientStorage() # Assert that the zeo cache is empty unless(not list(storage._cache.contents())) # Create the object oid = storage.new_oid() obj = MinPO(7) # We need to successfully commit an object now so we have something to # conflict about. t = Transaction() storage.tpc_begin(t) revid1a = storage.store(oid, ZERO, zodb_pickle(obj), '', t) revid1b = storage.tpc_vote(t) revid1 = handle_serials(oid, revid1a, revid1b) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 8 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) # Now sleep long enough for the storage to time out time.sleep(3) storage.sync() unless(not storage.is_connected()) storage._wait() unless(storage.is_connected()) # We expect finish to fail raises(ClientDisconnected, storage.tpc_finish, t) # Now we think we've committed the second transaction, but we really # haven't. A third one should produce a POSKeyError on the server, # which manifests as a ConflictError on the client. obj.value = 9 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) raises(ConflictError, storage.tpc_vote, t) # Even aborting won't help storage.tpc_abort(t) storage.tpc_finish(t) # Try again obj.value = 10 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) # Even aborting won't help raises(ConflictError, storage.tpc_vote, t) # Abort this one and try a transaction that should succeed storage.tpc_abort(t) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 11 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) storage.tpc_finish(t) # Now load the object and verify that it has a value of 11 data, revid = storage.load(oid, '') eq(zodb_unpickle(data), MinPO(11)) eq(revid, revid2)
|
4659d8eb20fb53ceb449f9082c96342b24dfed27 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/4659d8eb20fb53ceb449f9082c96342b24dfed27/ConnectionTests.py
|
||
def checkTimeoutProvokingConflicts(self): eq = self.assertEqual raises = self.assertRaises unless = self.failUnless self._storage = storage = self.openClientStorage() # Assert that the zeo cache is empty unless(not list(storage._cache.contents())) # Create the object oid = storage.new_oid() obj = MinPO(7) # We need to successfully commit an object now so we have something to # conflict about. t = Transaction() storage.tpc_begin(t) revid1a = storage.store(oid, ZERO, zodb_pickle(obj), '', t) revid1b = storage.tpc_vote(t) revid1 = handle_serials(oid, revid1a, revid1b) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 8 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) # Now sleep long enough for the storage to time out time.sleep(3) storage.sync() unless(not storage.is_connected()) storage._wait() unless(storage.is_connected()) # We expect finish to fail raises(ClientDisconnected, storage.tpc_finish, t) # Now we think we've committed the second transaction, but we really # haven't. A third one should produce a POSKeyError on the server, # which manifests as a ConflictError on the client. obj.value = 9 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) raises(ConflictError, storage.tpc_vote, t) # Even aborting won't help storage.tpc_abort(t) storage.tpc_finish(t) # Try again obj.value = 10 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) # Even aborting won't help raises(ConflictError, storage.tpc_vote, t) # Abort this one and try a transaction that should succeed storage.tpc_abort(t) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 11 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) storage.tpc_finish(t) # Now load the object and verify that it has a value of 11 data, revid = storage.load(oid, '') eq(zodb_unpickle(data), MinPO(11)) eq(revid, revid2)
|
4659d8eb20fb53ceb449f9082c96342b24dfed27 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/4659d8eb20fb53ceb449f9082c96342b24dfed27/ConnectionTests.py
|
||
def checkTimeoutProvokingConflicts(self): eq = self.assertEqual raises = self.assertRaises unless = self.failUnless self._storage = storage = self.openClientStorage() # Assert that the zeo cache is empty unless(not list(storage._cache.contents())) # Create the object oid = storage.new_oid() obj = MinPO(7) # We need to successfully commit an object now so we have something to # conflict about. t = Transaction() storage.tpc_begin(t) revid1a = storage.store(oid, ZERO, zodb_pickle(obj), '', t) revid1b = storage.tpc_vote(t) revid1 = handle_serials(oid, revid1a, revid1b) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 8 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) # Now sleep long enough for the storage to time out time.sleep(3) storage.sync() unless(not storage.is_connected()) storage._wait() unless(storage.is_connected()) # We expect finish to fail raises(ClientDisconnected, storage.tpc_finish, t) # Now we think we've committed the second transaction, but we really # haven't. A third one should produce a POSKeyError on the server, # which manifests as a ConflictError on the client. obj.value = 9 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) raises(ConflictError, storage.tpc_vote, t) # Even aborting won't help storage.tpc_abort(t) storage.tpc_finish(t) # Try again obj.value = 10 t = Transaction() storage.tpc_begin(t) storage.store(oid, revid2, zodb_pickle(obj), '', t) # Even aborting won't help raises(ConflictError, storage.tpc_vote, t) # Abort this one and try a transaction that should succeed storage.tpc_abort(t) storage.tpc_finish(t) # Now do a store, sleeping before the finish so as to cause a timeout obj.value = 11 t = Transaction() storage.tpc_begin(t) revid2a = storage.store(oid, revid1, zodb_pickle(obj), '', t) revid2b = storage.tpc_vote(t) revid2 = handle_serials(oid, revid2a, revid2b) storage.tpc_finish(t) # Now load the object and verify that it has a value of 11 data, revid = storage.load(oid, '') eq(zodb_unpickle(data), MinPO(11)) eq(revid, revid2)
|
4659d8eb20fb53ceb449f9082c96342b24dfed27 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/4659d8eb20fb53ceb449f9082c96342b24dfed27/ConnectionTests.py
|
||
if j is None: continue i=id(j) if not jars.has_key(i): jars[i]=j if subtransaction: subj[i]=j j.tpc_begin(self, subtransaction) else: j.tpc_begin(self) j.commit(o,self)
|
if j is not None: i=id(j) if not jars.has_key(i): jars[i]=j if subtransaction: subj[i]=j j.tpc_begin(self, subtransaction) else: j.tpc_begin(self) j.commit(o,self)
|
def commit(self, subtransaction=None): 'Finalize the transaction'
|
f6b665bb43c12dce05ecac9859e13781c2e76659 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/f6b665bb43c12dce05ecac9859e13781c2e76659/Transaction.py
|
line = f.readline() while line != "------\n":
|
line = f.readline().strip() while line != "------":
|
def verifyEntry(self, f, time=None, subsys=None, severity=None, summary=None, detail=None, error=None): # skip to the beginning of next entry line = f.readline() while line != "------\n": if not line: self.fail("can't find entry in log file") line = f.readline() line = f.readline().strip() _time, rest = line.split(" ", 1) if time is not None: self.assertEqual(_time, time) if subsys is not None: self.assert_(rest.find(subsys) != -1, "subsystem mismatch") if severity is not None and severity >= self._severity: s = severity_string[severity] self.assert_(rest.find(s) != -1, "severity mismatch") if summary is not None: self.assert_(rest.find(summary) != -1, "summary mismatch") if detail is not None: line = f.readline() self.assert_(line.find(detail) != -1, "missing detail") if error is not None: line = f.readline() self.assert_(line.startswith('Traceback'), "missing traceback") last = "%s: %s\n" % (error[0], error[1]) if last.startswith("exceptions."): last = last[len("exceptions."):] while 1: line = f.readline() if not line: self.fail("couldn't find end of traceback") if line == "------\n": self.fail("couldn't find end of traceback") if line == last: break
|
0b70a63bb11ec7470ed9211e2dfca57cc51203c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/0b70a63bb11ec7470ed9211e2dfca57cc51203c9/testzLog.py
|
line = f.readline()
|
line = f.readline().strip()
|
def verifyEntry(self, f, time=None, subsys=None, severity=None, summary=None, detail=None, error=None): # skip to the beginning of next entry line = f.readline() while line != "------\n": if not line: self.fail("can't find entry in log file") line = f.readline() line = f.readline().strip() _time, rest = line.split(" ", 1) if time is not None: self.assertEqual(_time, time) if subsys is not None: self.assert_(rest.find(subsys) != -1, "subsystem mismatch") if severity is not None and severity >= self._severity: s = severity_string[severity] self.assert_(rest.find(s) != -1, "severity mismatch") if summary is not None: self.assert_(rest.find(summary) != -1, "summary mismatch") if detail is not None: line = f.readline() self.assert_(line.find(detail) != -1, "missing detail") if error is not None: line = f.readline() self.assert_(line.startswith('Traceback'), "missing traceback") last = "%s: %s\n" % (error[0], error[1]) if last.startswith("exceptions."): last = last[len("exceptions."):] while 1: line = f.readline() if not line: self.fail("couldn't find end of traceback") if line == "------\n": self.fail("couldn't find end of traceback") if line == last: break
|
0b70a63bb11ec7470ed9211e2dfca57cc51203c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/0b70a63bb11ec7470ed9211e2dfca57cc51203c9/testzLog.py
|
last = "%s: %s\n" % (error[0], error[1])
|
last = "%s: %s" % (error[0], error[1])
|
def verifyEntry(self, f, time=None, subsys=None, severity=None, summary=None, detail=None, error=None): # skip to the beginning of next entry line = f.readline() while line != "------\n": if not line: self.fail("can't find entry in log file") line = f.readline() line = f.readline().strip() _time, rest = line.split(" ", 1) if time is not None: self.assertEqual(_time, time) if subsys is not None: self.assert_(rest.find(subsys) != -1, "subsystem mismatch") if severity is not None and severity >= self._severity: s = severity_string[severity] self.assert_(rest.find(s) != -1, "severity mismatch") if summary is not None: self.assert_(rest.find(summary) != -1, "summary mismatch") if detail is not None: line = f.readline() self.assert_(line.find(detail) != -1, "missing detail") if error is not None: line = f.readline() self.assert_(line.startswith('Traceback'), "missing traceback") last = "%s: %s\n" % (error[0], error[1]) if last.startswith("exceptions."): last = last[len("exceptions."):] while 1: line = f.readline() if not line: self.fail("couldn't find end of traceback") if line == "------\n": self.fail("couldn't find end of traceback") if line == last: break
|
0b70a63bb11ec7470ed9211e2dfca57cc51203c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/0b70a63bb11ec7470ed9211e2dfca57cc51203c9/testzLog.py
|
line = f.readline()
|
line = f.readline().strip()
|
def verifyEntry(self, f, time=None, subsys=None, severity=None, summary=None, detail=None, error=None): # skip to the beginning of next entry line = f.readline() while line != "------\n": if not line: self.fail("can't find entry in log file") line = f.readline() line = f.readline().strip() _time, rest = line.split(" ", 1) if time is not None: self.assertEqual(_time, time) if subsys is not None: self.assert_(rest.find(subsys) != -1, "subsystem mismatch") if severity is not None and severity >= self._severity: s = severity_string[severity] self.assert_(rest.find(s) != -1, "severity mismatch") if summary is not None: self.assert_(rest.find(summary) != -1, "summary mismatch") if detail is not None: line = f.readline() self.assert_(line.find(detail) != -1, "missing detail") if error is not None: line = f.readline() self.assert_(line.startswith('Traceback'), "missing traceback") last = "%s: %s\n" % (error[0], error[1]) if last.startswith("exceptions."): last = last[len("exceptions."):] while 1: line = f.readline() if not line: self.fail("couldn't find end of traceback") if line == "------\n": self.fail("couldn't find end of traceback") if line == last: break
|
0b70a63bb11ec7470ed9211e2dfca57cc51203c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/0b70a63bb11ec7470ed9211e2dfca57cc51203c9/testzLog.py
|
if line == "------\n":
|
if line == "------":
|
def verifyEntry(self, f, time=None, subsys=None, severity=None, summary=None, detail=None, error=None): # skip to the beginning of next entry line = f.readline() while line != "------\n": if not line: self.fail("can't find entry in log file") line = f.readline() line = f.readline().strip() _time, rest = line.split(" ", 1) if time is not None: self.assertEqual(_time, time) if subsys is not None: self.assert_(rest.find(subsys) != -1, "subsystem mismatch") if severity is not None and severity >= self._severity: s = severity_string[severity] self.assert_(rest.find(s) != -1, "severity mismatch") if summary is not None: self.assert_(rest.find(summary) != -1, "summary mismatch") if detail is not None: line = f.readline() self.assert_(line.find(detail) != -1, "missing detail") if error is not None: line = f.readline() self.assert_(line.startswith('Traceback'), "missing traceback") last = "%s: %s\n" % (error[0], error[1]) if last.startswith("exceptions."): last = last[len("exceptions."):] while 1: line = f.readline() if not line: self.fail("couldn't find end of traceback") if line == "------\n": self.fail("couldn't find end of traceback") if line == last: break
|
0b70a63bb11ec7470ed9211e2dfca57cc51203c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/0b70a63bb11ec7470ed9211e2dfca57cc51203c9/testzLog.py
|
i=i+22+vlen+dlen
|
i=i+14+vlen+dlen
|
def tpc_finish(self, transaction, f=None): self._lock_acquire() try: if transaction is not self._transaction: return if f is not None: f()
|
bd1e5a99ea27a969ebb0e73bd6dde8cc5b891bf2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/bd1e5a99ea27a969ebb0e73bd6dde8cc5b891bf2/ClientStorage.py
|
l=allocate_lock() self._a=l.acquire self._r=l.release self._pools={},[] self._temps=[] self._pool_size=pool_size self._cache_size=cache_size self._cache_deactivate_after=cache_deactivate_after self._version_pool_size=version_pool_size self._version_cache_size=version_cache_size self._version_cache_deactivate_after=version_cache_deactivate_after self._miv_cache={}
|
def __init__(self, storage, pool_size=7, cache_size=400, cache_deactivate_after=60, version_pool_size=3, version_cache_size=100, version_cache_deactivate_after=10, ): """Create an object database.
|
7d0a92de638e15c1ee62d04a8e74d8914b4f8dfd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/7d0a92de638e15c1ee62d04a8e74d8914b4f8dfd/DB.py
|
|
cs = ClientStorage(addr, storage=storage,
|
cs = ClientStorage(addr, storage=storage, debug=1,
|
def check_server(addr, storage): cs = ClientStorage(addr, storage=storage, wait_for_server_on_startup=0) # _startup() is an artifact of the way ZEO 1.0 works. The # ClientStorage doesn't get fully initialized until registerDB() # is called. The only thing we care about, though, is that # registerDB() calls _startup(). # XXX Is connecting a DB with wait_for_server_on_startup=0 a # sufficient test for upness? db = ZODB.DB(cs) db.close()
|
5718e5f8ab0d4f3eff35cd0c7426042366e9c7fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/5718e5f8ab0d4f3eff35cd0c7426042366e9c7fa/zeoup.py
|
cache.checkSize(size)
|
cache.checkSize(0)
|
def load(self, oid, version, _stuff=None): self._lock_acquire() try: cache=self._cache p = cache.load(oid, version) if p: return p p, s, v, pv, sv = self._call('zeoLoad', oid) cache.checkSize(size) cache.store(oid, p, s, v, pv, sv) if not v or not version or version != v: if s: return p, s raise KeyError, oid # no non-version data for this return pv, sv finally: self._lock_release()
|
05a6ce7e6ebd5c02608b9043b06a1af4fe010bf0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/05a6ce7e6ebd5c02608b9043b06a1af4fe010bf0/ClientStorage.py
|
print "newargs", repr(newargs)
|
def serialize(self, obj): # We don't use __class__ here, because obj could be a persistent proxy. # We don't want to be folled by proxies. klass = type(obj)
|
26ece502e64f921c5f8437dd28d0cbdd00c6b230 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/26ece502e64f921c5f8437dd28d0cbdd00c6b230/serialize.py
|
|
cmd = "%s %s" % (sys.executable, ZEO.start.__file__) if cmd[-1] == "c": cmd = cmd[:-1]
|
def removefs(base): """Remove all files created by FileStorage with path base.""" for ext in '', '.old', '.tmp', '.lock', '.index', '.pack': path = base + ext try: os.remove(path) except os.error, err: if err[0] != errno.ENOENT: raise
|
af6684f5113439ca6168551fb6389f0877cc8a9b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/af6684f5113439ca6168551fb6389f0877cc8a9b/testStart.py
|
|
self.env = Environment(self.cmd)
|
def setUp(self): self.pids = {} self.env = Environment(self.cmd)
|
af6684f5113439ca6168551fb6389f0877cc8a9b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/af6684f5113439ca6168551fb6389f0877cc8a9b/testStart.py
|
|
buf1 = open(logfile1).read()
|
for i in range(10): try: buf1 = open(logfile1).read() except IOError, e: if e.errno != errno.ENOENT: raise time.sleep(1) else: break
|
def testLogRestart(self): port = 9090 logfile1 = tempfile.mktemp(suffix="log") logfile2 = tempfile.mktemp(suffix="log") os.environ["EVENT_LOG_FILE"] = logfile1
|
af6684f5113439ca6168551fb6389f0877cc8a9b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/af6684f5113439ca6168551fb6389f0877cc8a9b/testStart.py
|
t=self.t t.update([(1,1),(5,5),(9,9)]) self.assertEqual(list(t.keys(-6,-4)),[], list(t.keys(-6,-4))) self.assertEqual(list(t.keys(2,4)),[], list(t.keys(2,4))) self.assertEqual(list(t.keys(6,8)),[], list(t.keys(6,8))) self.assertEqual(list(t.keys(10,12)),[], list(t.keys(10,12)))
|
t = self.t t.update([(1,1), (5,5), (9,9)]) self.assertEqual(list(t.keys(-6,-4)), [], list(t.keys(-6,-4))) self.assertEqual(list(t.keys(2,4)), [], list(t.keys(2,4))) self.assertEqual(list(t.keys(6,8)), [], list(t.keys(6,8))) self.assertEqual(list(t.keys(10,12)), [], list(t.keys(10,12))) self.assertEqual(list(t.keys(9, 1)), [], list(t.keys(9, 1)))
|
def testEmptyRangeSearches(self): t=self.t t.update([(1,1),(5,5),(9,9)]) self.assertEqual(list(t.keys(-6,-4)),[], list(t.keys(-6,-4))) self.assertEqual(list(t.keys(2,4)),[], list(t.keys(2,4))) self.assertEqual(list(t.keys(6,8)),[], list(t.keys(6,8))) self.assertEqual(list(t.keys(10,12)),[], list(t.keys(10,12)))
|
90a7d5e264ce24fe29400d7fd7322ed3c033aedf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/90a7d5e264ce24fe29400d7fd7322ed3c033aedf/testBTrees.py
|
t=self.t t.update([1,5,9]) self.assertEqual(list(t.keys(-6,-4)),[], list(t.keys(-6,-4))) self.assertEqual(list(t.keys(2,4)),[], list(t.keys(2,4))) self.assertEqual(list(t.keys(6,8)),[], list(t.keys(6,8))) self.assertEqual(list(t.keys(10,12)),[], list(t.keys(10,12)))
|
t = self.t t.update([1, 5, 9]) self.assertEqual(list(t.keys(-6,-4)), [], list(t.keys(-6,-4))) self.assertEqual(list(t.keys(2,4)), [], list(t.keys(2,4))) self.assertEqual(list(t.keys(6,8)), [], list(t.keys(6,8))) self.assertEqual(list(t.keys(10,12)), [], list(t.keys(10,12))) self.assertEqual(list(t.keys(9,1)), [], list(t.keys(9,1)))
|
def testEmptyRangeSearches(self): t=self.t t.update([1,5,9]) self.assertEqual(list(t.keys(-6,-4)),[], list(t.keys(-6,-4))) self.assertEqual(list(t.keys(2,4)),[], list(t.keys(2,4))) self.assertEqual(list(t.keys(6,8)),[], list(t.keys(6,8))) self.assertEqual(list(t.keys(10,12)),[], list(t.keys(10,12)))
|
90a7d5e264ce24fe29400d7fd7322ed3c033aedf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/90a7d5e264ce24fe29400d7fd7322ed3c033aedf/testBTrees.py
|
class ConnectionTests(StorageTestBase.StorageTestBase):
|
class ConnectionTests(StorageTestBase):
|
def invalidate(self, *args): pass
|
3cd508c395275293f366cb0b9dcf0fa90db32808 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/3cd508c395275293f366cb0b9dcf0fa90db32808/ConnectionTests.py
|
__super_tearDown = StorageTestBase.StorageTestBase.tearDown
|
__super_setUp = StorageTestBase.setUp __super_tearDown = StorageTestBase.tearDown
|
def invalidate(self, *args): pass
|
3cd508c395275293f366cb0b9dcf0fa90db32808 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/3cd508c395275293f366cb0b9dcf0fa90db32808/ConnectionTests.py
|
"""Start a ZEO server using a Unix domain socket The ZEO server uses the storage object returned by the getStorage() method.
|
"""Test setup for connection tests. This starts only one server; a test may start more servers by calling self._newAddr() and then self.startServer(index=i) for i in 1, 2, ...
|
def setUp(self): """Start a ZEO server using a Unix domain socket
|
3cd508c395275293f366cb0b9dcf0fa90db32808 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/3cd508c395275293f366cb0b9dcf0fa90db32808/ConnectionTests.py
|
read_only=0, read_only_fallback=0): base = ClientStorage(self.addr, client=cache, cache_size=cache_size, wait=wait, min_disconnect_poll=0.1, read_only=read_only, read_only_fallback=read_only_fallback) storage = base
|
read_only=0, read_only_fallback=0, addr=None): if addr is None: addr = self.addr storage = ClientStorage(addr, client=cache, cache_size=cache_size, wait=wait, min_disconnect_poll=0.1, read_only=read_only, read_only_fallback=read_only_fallback)
|
def openClientStorage(self, cache='', cache_size=200000, wait=1, read_only=0, read_only_fallback=0): base = ClientStorage(self.addr, client=cache, cache_size=cache_size, wait=wait, min_disconnect_poll=0.1, read_only=read_only, read_only_fallback=read_only_fallback) storage = base storage.registerDB(DummyDB(), None) return storage
|
3cd508c395275293f366cb0b9dcf0fa90db32808 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/3cd508c395275293f366cb0b9dcf0fa90db32808/ConnectionTests.py
|
select.error, thread.error, socket.error):
|
select.error, threading.ThreadError, socket.error):
|
def checkReconnectSwitch(self): # A fallback client initially connects to a read-only server, # then discovers a read-write server and switches to that
|
3cd508c395275293f366cb0b9dcf0fa90db32808 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/3cd508c395275293f366cb0b9dcf0fa90db32808/ConnectionTests.py
|
except (Disconnected, select.error, thread.error, socket.error):
|
except (Disconnected, select.error, threading.ThreadError, socket.error):
|
def checkReconnection(self): # Check that the client reconnects when a server restarts.
|
3cd508c395275293f366cb0b9dcf0fa90db32808 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/3cd508c395275293f366cb0b9dcf0fa90db32808/ConnectionTests.py
|
self._reader = ConnectionObjectReader(self, self._cache, self._db._classFactory)
|
def _setDB(self, odb): """Begin a new transaction.
|
00df8ddb2f0ffbd0c7851f816907bd6c2dd2d4ac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/00df8ddb2f0ffbd0c7851f816907bd6c2dd2d4ac/Connection.py
|
|
os.environ["EVENT_LOG_FILE"] = logfile1
|
os.environ["STUPID_LOG_FILE"] = logfile1
|
def testLogRestart(self): port = 9090 logfile1 = tempfile.mktemp(suffix="log") logfile2 = tempfile.mktemp(suffix="log") os.environ["EVENT_LOG_FILE"] = logfile1
|
7b10d3209d559e3cd9a61fbf21399fb4d3105346 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/7b10d3209d559e3cd9a61fbf21399fb4d3105346/testStart.py
|
if e.errno != errno.ENOENT: raise
|
if e.errno != errno.ENOENT: raise
|
def testLogRestart(self): port = 9090 logfile1 = tempfile.mktemp(suffix="log") logfile2 = tempfile.mktemp(suffix="log") os.environ["EVENT_LOG_FILE"] = logfile1
|
7b10d3209d559e3cd9a61fbf21399fb4d3105346 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/7b10d3209d559e3cd9a61fbf21399fb4d3105346/testStart.py
|
_CONNECT_OK = (0, errno.WSAEISCONN)
|
_CONNECT_OK = (0, errno.WSAEISCONN, errno.WSAEINVAL)
|
def notify_closed(self): self.connected = 0 self.connection = None self.client.notifyDisconnected() if not self.closed: self.connect()
|
a55666701792933dbb53c9afe235a02a52b1f0d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/a55666701792933dbb53c9afe235a02a52b1f0d5/client.py
|
self._db=self._storage=self._tmp=self.new_oid=None
|
self._db=self._storage=self._tmp=self.new_oid=self._opened=None self._debug_info=()
|
def close(self): self._incrgc() db=self._db self._db=self._storage=self._tmp=self.new_oid=None db._closeConnection(self)
|
a2ccfe682ea4437462606a5a717ac50675f30fa6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/a2ccfe682ea4437462606a5a717ac50675f30fa6/Connection.py
|
def set_uid(uid):
|
def set_uid(arg):
|
def set_uid(uid): """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 Server', INFO, ("Can't set uid to %s." "pwd module is not available." % uid)) return try: gid = None try: UID = int(UID) except: # conversion could raise all sorts of errors uid = pwd.getpwnam(UID)[2] gid = pwd.getpwnam(UID)[3] else: uid = pwd.getpwuid(UID)[2] gid = pwd.getpwuid(UID)[3] if gid is not None: try: os.setgid(gid) except OSError: pass try: os.setuid(uid) except OSError: pass except KeyError: LOG('ZEO Server', ERROR, ("can't find UID %s" % UID))
|
3378c28d5e3dfbc3c53e6a2b96b066c4ea964887 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/3378c28d5e3dfbc3c53e6a2b96b066c4ea964887/start.py
|
UID = int(UID)
|
arg = int(arg)
|
def set_uid(uid): """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 Server', INFO, ("Can't set uid to %s." "pwd module is not available." % uid)) return try: gid = None try: UID = int(UID) except: # conversion could raise all sorts of errors uid = pwd.getpwnam(UID)[2] gid = pwd.getpwnam(UID)[3] else: uid = pwd.getpwuid(UID)[2] gid = pwd.getpwuid(UID)[3] if gid is not None: try: os.setgid(gid) except OSError: pass try: os.setuid(uid) except OSError: pass except KeyError: LOG('ZEO Server', ERROR, ("can't find UID %s" % UID))
|
3378c28d5e3dfbc3c53e6a2b96b066c4ea964887 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/3378c28d5e3dfbc3c53e6a2b96b066c4ea964887/start.py
|
uid = pwd.getpwnam(UID)[2] gid = pwd.getpwnam(UID)[3]
|
uid = pwd.getpwnam(arg)[2] gid = pwd.getpwnam(arg)[3]
|
def set_uid(uid): """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 Server', INFO, ("Can't set uid to %s." "pwd module is not available." % uid)) return try: gid = None try: UID = int(UID) except: # conversion could raise all sorts of errors uid = pwd.getpwnam(UID)[2] gid = pwd.getpwnam(UID)[3] else: uid = pwd.getpwuid(UID)[2] gid = pwd.getpwuid(UID)[3] if gid is not None: try: os.setgid(gid) except OSError: pass try: os.setuid(uid) except OSError: pass except KeyError: LOG('ZEO Server', ERROR, ("can't find UID %s" % UID))
|
3378c28d5e3dfbc3c53e6a2b96b066c4ea964887 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/3378c28d5e3dfbc3c53e6a2b96b066c4ea964887/start.py
|
uid = pwd.getpwuid(UID)[2] gid = pwd.getpwuid(UID)[3]
|
uid = pwd.getpwuid(arg)[2] gid = pwd.getpwuid(arg)[3]
|
def set_uid(uid): """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 Server', INFO, ("Can't set uid to %s." "pwd module is not available." % uid)) return try: gid = None try: UID = int(UID) except: # conversion could raise all sorts of errors uid = pwd.getpwnam(UID)[2] gid = pwd.getpwnam(UID)[3] else: uid = pwd.getpwuid(UID)[2] gid = pwd.getpwuid(UID)[3] if gid is not None: try: os.setgid(gid) except OSError: pass try: os.setuid(uid) except OSError: pass except KeyError: LOG('ZEO Server', ERROR, ("can't find UID %s" % UID))
|
3378c28d5e3dfbc3c53e6a2b96b066c4ea964887 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/3378c28d5e3dfbc3c53e6a2b96b066c4ea964887/start.py
|
LOG('ZEO Server', ERROR, ("can't find UID %s" % UID))
|
LOG('ZEO Server', ERROR, ("can't find uid %s" % arg))
|
def set_uid(uid): """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 Server', INFO, ("Can't set uid to %s." "pwd module is not available." % uid)) return try: gid = None try: UID = int(UID) except: # conversion could raise all sorts of errors uid = pwd.getpwnam(UID)[2] gid = pwd.getpwnam(UID)[3] else: uid = pwd.getpwuid(UID)[2] gid = pwd.getpwuid(UID)[3] if gid is not None: try: os.setgid(gid) except OSError: pass try: os.setuid(uid) except OSError: pass except KeyError: LOG('ZEO Server', ERROR, ("can't find UID %s" % UID))
|
3378c28d5e3dfbc3c53e6a2b96b066c4ea964887 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/3378c28d5e3dfbc3c53e6a2b96b066c4ea964887/start.py
|
set_uid(uid)
|
set_uid(UID)
|
def main(argv): me = argv[0] sys.path.insert(0, directory(me, 2)) global LOG, INFO, ERROR from zLOG import LOG, INFO, ERROR, PANIC # XXX hack for profiling support global unix, storages, zeo_pid, asyncore args = [] last = '' for a in argv[1:]: if (a[:1] != '-' and a.find('=') > 0 and last != '-S'): # lame, sorry a = a.split("=") os.environ[a[0]] = "=".join(a[1:]) continue args.append(a) last = a if os.environ.has_key('INSTANCE_HOME'): INSTANCE_HOME = os.environ['INSTANCE_HOME'] elif os.path.isdir(os.path.join(directory(me, 4),'var')): INSTANCE_HOME = directory(me, 4) else: INSTANCE_HOME = os.getcwd() if os.path.isdir(os.path.join(INSTANCE_HOME, 'var')): var = os.path.join(INSTANCE_HOME, 'var') else: var = INSTANCE_HOME zeo_pid = os.environ.get('ZEO_SERVER_PID', os.path.join(var, 'ZEO_SERVER.pid')) fs = os.path.join(var, 'Data.fs') usage="""%s [options] [filename] where options are: -D -- Run in debug mode -d -- Set STUPD_LOG_SEVERITY to -300 -U -- Unix-domain socket file to listen on -u username or uid number The username to run the ZEO server as. You may want to run the ZEO server as 'nobody' or some other user with limited resouces. The only works under Unix, and if ZServer is started by root. -p port -- port to listen on -h adddress -- host address to listen on -s -- Don't use zdeamon -S storage_name=module_path:attr_name -- A storage specification where: storage_name -- is the storage name used in the ZEO protocol. This is the name that you give as the optional 'storage' keyword argument to the ClientStorage constructor. module_path -- This is the path to a Python module that defines the storage object(s) to be served. The module path should ommit the prefix (e.g. '.py'). attr_name -- This is the name to which the storage object is assigned in the module. -P file -- Run under profile and dump output to file. Implies the -s flag. if no file name is specified, then %s is used. """ % (me, fs) try: opts, args = getopt.getopt(args, 'p:Dh:U:sS:u:P:d') except getopt.error, msg: print usage print msg sys.exit(1) port = None debug = 0 host = '' unix =None Z = 1 UID = 'nobody' prof = None detailed = 0 for o, v in opts: if o =='-p': port = int(v) elif o =='-h': host = v elif o =='-U': unix = v elif o =='-u': UID = v elif o =='-D': debug = 1 elif o =='-d': detailed = 1 elif o =='-s': Z = 0 elif o =='-P': prof = v if prof: Z = 0 if port is None and unix is None: print usage print 'No port specified.' sys.exit(1) if args: if len(args) > 1: print usage print 'Unrecognizd arguments: ', " ".join(args[1:]) sys.exit(1) fs = args[0]
|
3378c28d5e3dfbc3c53e6a2b96b066c4ea964887 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/3378c28d5e3dfbc3c53e6a2b96b066c4ea964887/start.py
|
def __init__(self, file_name, create=0, read_only=0, stop=None):
|
def __init__(self, file_name, create=0, read_only=0, stop=None, quota=None):
|
def __init__(self, file_name, create=0, read_only=0, stop=None):
|
87bee8b0fb95aebc3396958c67c3f4c465c4e4e3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/87bee8b0fb95aebc3396958c67c3f4c465c4e4e3/FileStorage.py
|
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) cp(tfile, file, dlen) write(stl) file.seek(pos+16) write(' ') file.flush()
|
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) cp(tfile, file, dlen) write(stl) file.seek(pos+16) write(' ') file.flush() except: file.truncate(pos)
|
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
|
87bee8b0fb95aebc3396958c67c3f4c465c4e4e3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/87bee8b0fb95aebc3396958c67c3f4c465c4e4e3/FileStorage.py
|
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()
|
_truncate(file, name, pos)
|
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) 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 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
|
87bee8b0fb95aebc3396958c67c3f4c465c4e4e3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/87bee8b0fb95aebc3396958c67c3f4c465c4e4e3/FileStorage.py
|
if ul > tl or dl > tl or el > tl: panic('%s has invalid transaction header at %s', name, pos)
|
if ul > tl or dl > tl or el > tl or tl < (23+ul+dl+el): seek(-8, 2) rtl=u64(read(8)) 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)
|
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) 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 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
|
87bee8b0fb95aebc3396958c67c3f4c465c4e4e3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/87bee8b0fb95aebc3396958c67c3f4c465c4e4e3/FileStorage.py
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.