rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
pnv=u64(read(8))
pnv=U64(read(8))
def pack(self, t, referencesf): """Copy data from the current database file to a packed file Non-current records from transactions with time-stamp strings less than packtss are ommitted. As are all undone records. Also, data back pointers that point before packtss are resolved and the associated data are copied, since the old records are not copied. """
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
p=u64(p)
p=U64(p)
def pack(self, t, referencesf): """Copy data from the current database file to a packed file Non-current records from transactions with time-stamp strings less than packtss are ommitted. As are all undone records. Also, data back pointers that point before packtss are resolved and the associated data are copied, since the old records are not copied. """
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
if el < 0: el=t32-el tl=u64(stl)
tl=U64(stl)
def shift_transactions_forward(index, vindex, tindex, file, pos, opos): """Copy transactions forward in the data file This might be done as part of a recovery effort """ # Cache a bunch of methods seek=file.seek read=file.read write=file.write tappend=tindex.append index_get=index.get vindex_get=vindex.get # Initialize, pv=z64 p1=opos p2=pos offset=p2-p1 packpos=opos # Copy the data in two stages. In the packing stage, # we skip records that are non-current or that are for # unreferenced objects. We also skip undone transactions. # # After the packing stage, we copy everything but undone # transactions, however, we have to update various back pointers. # We have to have the storage lock in the second phase to keep # data from being changed while we're copying. pnv=None while 1: # Read the transaction record seek(pos) h=read(23) if len(h) < 23: break tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if status=='c': break # Oops. we found a checkpoint flag. if el < 0: el=t32-el tl=u64(stl) tpos=pos tend=tpos+tl otpos=opos # start pos of output trans thl=ul+dl+el h2=read(thl) if len(h2) != thl: raise 'Pack Error', opos # write out the transaction record seek(opos) write(h) write(h2) thl=23+thl pos=tpos+thl opos=otpos+thl while pos < tend: # Read the data records for this transaction seek(pos) h=read(42) oid,serial,sprev,stloc,vlen,splen = unpack(">8s8s8s8sH8s", h) plen=u64(splen) dlen=42+(plen or 8) if vlen: dlen=dlen+16+vlen pnv=u64(read(8)) # skip position of previous version record seek(8,1) version=read(vlen) pv=p64(vindex_get(version, 0)) if status != 'u': vindex[version]=opos tappend((oid,opos)) if plen: p=read(plen) else: p=read(8) p=u64(p) if p >= p2: p=p-offset elif p >= p1: # Ick, we're in trouble. Let's bail # to the index and hope for the best p=index_get(oid,0) p=p64(p) # WRITE seek(opos) sprev=p64(index_get(oid,0)) write(pack(">8s8s8s8sH8s", oid,serial,sprev,p64(otpos),vlen,splen)) if vlen: if not pnv: write(z64) else: if pnv >= p2: pnv=pnv-offset elif pnv >= p1: pnv=index_get(oid,0) write(p64(pnv)) write(pv) write(version) write(p) opos=opos+dlen pos=pos+dlen # skip the (intentionally redundant) transaction length pos=pos+8 if status != 'u': for oid, p in tindex: index[oid]=p # Record the position del tindex[:] write(stl) opos=opos+8 return opos
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
plen=u64(splen)
plen=U64(splen)
def shift_transactions_forward(index, vindex, tindex, file, pos, opos): """Copy transactions forward in the data file This might be done as part of a recovery effort """ # Cache a bunch of methods seek=file.seek read=file.read write=file.write tappend=tindex.append index_get=index.get vindex_get=vindex.get # Initialize, pv=z64 p1=opos p2=pos offset=p2-p1 packpos=opos # Copy the data in two stages. In the packing stage, # we skip records that are non-current or that are for # unreferenced objects. We also skip undone transactions. # # After the packing stage, we copy everything but undone # transactions, however, we have to update various back pointers. # We have to have the storage lock in the second phase to keep # data from being changed while we're copying. pnv=None while 1: # Read the transaction record seek(pos) h=read(23) if len(h) < 23: break tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if status=='c': break # Oops. we found a checkpoint flag. if el < 0: el=t32-el tl=u64(stl) tpos=pos tend=tpos+tl otpos=opos # start pos of output trans thl=ul+dl+el h2=read(thl) if len(h2) != thl: raise 'Pack Error', opos # write out the transaction record seek(opos) write(h) write(h2) thl=23+thl pos=tpos+thl opos=otpos+thl while pos < tend: # Read the data records for this transaction seek(pos) h=read(42) oid,serial,sprev,stloc,vlen,splen = unpack(">8s8s8s8sH8s", h) plen=u64(splen) dlen=42+(plen or 8) if vlen: dlen=dlen+16+vlen pnv=u64(read(8)) # skip position of previous version record seek(8,1) version=read(vlen) pv=p64(vindex_get(version, 0)) if status != 'u': vindex[version]=opos tappend((oid,opos)) if plen: p=read(plen) else: p=read(8) p=u64(p) if p >= p2: p=p-offset elif p >= p1: # Ick, we're in trouble. Let's bail # to the index and hope for the best p=index_get(oid,0) p=p64(p) # WRITE seek(opos) sprev=p64(index_get(oid,0)) write(pack(">8s8s8s8sH8s", oid,serial,sprev,p64(otpos),vlen,splen)) if vlen: if not pnv: write(z64) else: if pnv >= p2: pnv=pnv-offset elif pnv >= p1: pnv=index_get(oid,0) write(p64(pnv)) write(pv) write(version) write(p) opos=opos+dlen pos=pos+dlen # skip the (intentionally redundant) transaction length pos=pos+8 if status != 'u': for oid, p in tindex: index[oid]=p # Record the position del tindex[:] write(stl) opos=opos+8 return opos
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
dlen=dlen+16+vlen pnv=u64(read(8))
dlen=dlen+(16+vlen) pnv=U64(read(8))
def shift_transactions_forward(index, vindex, tindex, file, pos, opos): """Copy transactions forward in the data file This might be done as part of a recovery effort """ # Cache a bunch of methods seek=file.seek read=file.read write=file.write tappend=tindex.append index_get=index.get vindex_get=vindex.get # Initialize, pv=z64 p1=opos p2=pos offset=p2-p1 packpos=opos # Copy the data in two stages. In the packing stage, # we skip records that are non-current or that are for # unreferenced objects. We also skip undone transactions. # # After the packing stage, we copy everything but undone # transactions, however, we have to update various back pointers. # We have to have the storage lock in the second phase to keep # data from being changed while we're copying. pnv=None while 1: # Read the transaction record seek(pos) h=read(23) if len(h) < 23: break tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if status=='c': break # Oops. we found a checkpoint flag. if el < 0: el=t32-el tl=u64(stl) tpos=pos tend=tpos+tl otpos=opos # start pos of output trans thl=ul+dl+el h2=read(thl) if len(h2) != thl: raise 'Pack Error', opos # write out the transaction record seek(opos) write(h) write(h2) thl=23+thl pos=tpos+thl opos=otpos+thl while pos < tend: # Read the data records for this transaction seek(pos) h=read(42) oid,serial,sprev,stloc,vlen,splen = unpack(">8s8s8s8sH8s", h) plen=u64(splen) dlen=42+(plen or 8) if vlen: dlen=dlen+16+vlen pnv=u64(read(8)) # skip position of previous version record seek(8,1) version=read(vlen) pv=p64(vindex_get(version, 0)) if status != 'u': vindex[version]=opos tappend((oid,opos)) if plen: p=read(plen) else: p=read(8) p=u64(p) if p >= p2: p=p-offset elif p >= p1: # Ick, we're in trouble. Let's bail # to the index and hope for the best p=index_get(oid,0) p=p64(p) # WRITE seek(opos) sprev=p64(index_get(oid,0)) write(pack(">8s8s8s8sH8s", oid,serial,sprev,p64(otpos),vlen,splen)) if vlen: if not pnv: write(z64) else: if pnv >= p2: pnv=pnv-offset elif pnv >= p1: pnv=index_get(oid,0) write(p64(pnv)) write(pv) write(version) write(p) opos=opos+dlen pos=pos+dlen # skip the (intentionally redundant) transaction length pos=pos+8 if status != 'u': for oid, p in tindex: index[oid]=p # Record the position del tindex[:] write(stl) opos=opos+8 return opos
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
p=u64(p)
p=U64(p)
def shift_transactions_forward(index, vindex, tindex, file, pos, opos): """Copy transactions forward in the data file This might be done as part of a recovery effort """ # Cache a bunch of methods seek=file.seek read=file.read write=file.write tappend=tindex.append index_get=index.get vindex_get=vindex.get # Initialize, pv=z64 p1=opos p2=pos offset=p2-p1 packpos=opos # Copy the data in two stages. In the packing stage, # we skip records that are non-current or that are for # unreferenced objects. We also skip undone transactions. # # After the packing stage, we copy everything but undone # transactions, however, we have to update various back pointers. # We have to have the storage lock in the second phase to keep # data from being changed while we're copying. pnv=None while 1: # Read the transaction record seek(pos) h=read(23) if len(h) < 23: break tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if status=='c': break # Oops. we found a checkpoint flag. if el < 0: el=t32-el tl=u64(stl) tpos=pos tend=tpos+tl otpos=opos # start pos of output trans thl=ul+dl+el h2=read(thl) if len(h2) != thl: raise 'Pack Error', opos # write out the transaction record seek(opos) write(h) write(h2) thl=23+thl pos=tpos+thl opos=otpos+thl while pos < tend: # Read the data records for this transaction seek(pos) h=read(42) oid,serial,sprev,stloc,vlen,splen = unpack(">8s8s8s8sH8s", h) plen=u64(splen) dlen=42+(plen or 8) if vlen: dlen=dlen+16+vlen pnv=u64(read(8)) # skip position of previous version record seek(8,1) version=read(vlen) pv=p64(vindex_get(version, 0)) if status != 'u': vindex[version]=opos tappend((oid,opos)) if plen: p=read(plen) else: p=read(8) p=u64(p) if p >= p2: p=p-offset elif p >= p1: # Ick, we're in trouble. Let's bail # to the index and hope for the best p=index_get(oid,0) p=p64(p) # WRITE seek(opos) sprev=p64(index_get(oid,0)) write(pack(">8s8s8s8sH8s", oid,serial,sprev,p64(otpos),vlen,splen)) if vlen: if not pnv: write(z64) else: if pnv >= p2: pnv=pnv-offset elif pnv >= p1: pnv=index_get(oid,0) write(p64(pnv)) write(pv) write(version) write(p) opos=opos+dlen pos=pos+dlen # skip the (intentionally redundant) transaction length pos=pos+8 if status != 'u': for oid, p in tindex: index[oid]=p # Record the position del tindex[:] write(stl) opos=opos+8 return opos
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
l=u64(read(8))
l=U64(read(8))
def search_back(file, pos): seek=file.seek read=file.read seek(0,2) s=p=file.tell() while p > pos: seek(p-8) l=u64(read(8)) if l <= 0: break p=p-l-8 return p, s
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
ltid=z64, start=4, maxoid=z64, recover=0):
ltid=z64, start=4L, maxoid=z64, recover=0):
def read_index(file, name, index, vindex, tindex, stop='\377'*8, ltid=z64, start=4, maxoid=z64, recover=0): read=file.read seek=file.seek seek(0,2) file_size=file.tell() if file_size: if file_size < start: raise FileStorageFormatError, file.name seek(0) if read(4) != packed_version: raise FileStorageFormatError, name else: file.write(packed_version) return 4, maxoid, ltid index_get=index.get vndexpos=vindex.get tappend=tindex.append pos=start seek(start) unpack=struct.unpack tpos=0 tid='\0'*7+'\1' while 1: # Read the transaction record h=read(23) if not h: break if len(h) != 23: warn('%s truncated at %s', name, pos) seek(pos) file.truncate() break tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el if tid <= ltid: warn("%s time-stamp reduction at %s", name, pos) ltid=tid tl=u64(stl) if tl+pos+8 > file_size or status=='c': # Hm, the data were truncated or the checkpoint flag wasn't # cleared. They may also be corrupted, # in which case, we don't want to totally lose the data. warn("%s truncated, possibly due to damaged records at %s", name, pos) _truncate(file, name, pos) break if status not in ' up': warn('%s has invalid status, %s, at %s', name, status, pos) if ul > tl or dl > tl or el > tl or tl < (23+ul+dl+el): # We're in trouble. Find out if this is bad data in the # middle of the file, or just a turd that Win 9x dropped # at the end when the system crashed. # Skip to the end and read what should be the transaction length # of the last transaction. seek(-8, 2) rtl=u64(read(8)) # Now check to see if the redundant transaction length is # reasonable: if file_size - rtl < pos or rtl < 23: nearPanic('%s has invalid transaction header at %s', name, pos) warn("It appears that there is invalid data at the end of the " "file, possibly due to a system crash. %s truncated " "to recover from bad data at end." % name) _truncate(file, name, pos) break else: if recover: return tpos, None, None 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: if recover: return tpos, None, None 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)) 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: if recover: return tpos, None, None panic("%s data record exceeds transaction record at %s", name, pos) if index_get(oid,0) != prev: if prev: if recover: return tpos, None, None panic("%s incorrect previous pointer at %s", name, pos) else: warn("%s incorrect previous pointer at %s", name, pos) pos=pos+dlen if pos != tend: if recover: return tpos, None, None 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: if recover: return tpos, None, None 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
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
return 4, maxoid, ltid
return 4L, maxoid, ltid
def read_index(file, name, index, vindex, tindex, stop='\377'*8, ltid=z64, start=4, maxoid=z64, recover=0): read=file.read seek=file.seek seek(0,2) file_size=file.tell() if file_size: if file_size < start: raise FileStorageFormatError, file.name seek(0) if read(4) != packed_version: raise FileStorageFormatError, name else: file.write(packed_version) return 4, maxoid, ltid index_get=index.get vndexpos=vindex.get tappend=tindex.append pos=start seek(start) unpack=struct.unpack tpos=0 tid='\0'*7+'\1' while 1: # Read the transaction record h=read(23) if not h: break if len(h) != 23: warn('%s truncated at %s', name, pos) seek(pos) file.truncate() break tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el if tid <= ltid: warn("%s time-stamp reduction at %s", name, pos) ltid=tid tl=u64(stl) if tl+pos+8 > file_size or status=='c': # Hm, the data were truncated or the checkpoint flag wasn't # cleared. They may also be corrupted, # in which case, we don't want to totally lose the data. warn("%s truncated, possibly due to damaged records at %s", name, pos) _truncate(file, name, pos) break if status not in ' up': warn('%s has invalid status, %s, at %s', name, status, pos) if ul > tl or dl > tl or el > tl or tl < (23+ul+dl+el): # We're in trouble. Find out if this is bad data in the # middle of the file, or just a turd that Win 9x dropped # at the end when the system crashed. # Skip to the end and read what should be the transaction length # of the last transaction. seek(-8, 2) rtl=u64(read(8)) # Now check to see if the redundant transaction length is # reasonable: if file_size - rtl < pos or rtl < 23: nearPanic('%s has invalid transaction header at %s', name, pos) warn("It appears that there is invalid data at the end of the " "file, possibly due to a system crash. %s truncated " "to recover from bad data at end." % name) _truncate(file, name, pos) break else: if recover: return tpos, None, None 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: if recover: return tpos, None, None 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)) 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: if recover: return tpos, None, None panic("%s data record exceeds transaction record at %s", name, pos) if index_get(oid,0) != prev: if prev: if recover: return tpos, None, None panic("%s incorrect previous pointer at %s", name, pos) else: warn("%s incorrect previous pointer at %s", name, pos) pos=pos+dlen if pos != tend: if recover: return tpos, None, None 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: if recover: return tpos, None, None 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
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
tpos=0
def read_index(file, name, index, vindex, tindex, stop='\377'*8, ltid=z64, start=4, maxoid=z64, recover=0): read=file.read seek=file.seek seek(0,2) file_size=file.tell() if file_size: if file_size < start: raise FileStorageFormatError, file.name seek(0) if read(4) != packed_version: raise FileStorageFormatError, name else: file.write(packed_version) return 4, maxoid, ltid index_get=index.get vndexpos=vindex.get tappend=tindex.append pos=start seek(start) unpack=struct.unpack tpos=0 tid='\0'*7+'\1' while 1: # Read the transaction record h=read(23) if not h: break if len(h) != 23: warn('%s truncated at %s', name, pos) seek(pos) file.truncate() break tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el if tid <= ltid: warn("%s time-stamp reduction at %s", name, pos) ltid=tid tl=u64(stl) if tl+pos+8 > file_size or status=='c': # Hm, the data were truncated or the checkpoint flag wasn't # cleared. They may also be corrupted, # in which case, we don't want to totally lose the data. warn("%s truncated, possibly due to damaged records at %s", name, pos) _truncate(file, name, pos) break if status not in ' up': warn('%s has invalid status, %s, at %s', name, status, pos) if ul > tl or dl > tl or el > tl or tl < (23+ul+dl+el): # We're in trouble. Find out if this is bad data in the # middle of the file, or just a turd that Win 9x dropped # at the end when the system crashed. # Skip to the end and read what should be the transaction length # of the last transaction. seek(-8, 2) rtl=u64(read(8)) # Now check to see if the redundant transaction length is # reasonable: if file_size - rtl < pos or rtl < 23: nearPanic('%s has invalid transaction header at %s', name, pos) warn("It appears that there is invalid data at the end of the " "file, possibly due to a system crash. %s truncated " "to recover from bad data at end." % name) _truncate(file, name, pos) break else: if recover: return tpos, None, None 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: if recover: return tpos, None, None 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)) 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: if recover: return tpos, None, None panic("%s data record exceeds transaction record at %s", name, pos) if index_get(oid,0) != prev: if prev: if recover: return tpos, None, None panic("%s incorrect previous pointer at %s", name, pos) else: warn("%s incorrect previous pointer at %s", name, pos) pos=pos+dlen if pos != tend: if recover: return tpos, None, None 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: if recover: return tpos, None, None 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
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
tl=u64(stl) if tl+pos+8 > file_size or status=='c':
tl=U64(stl) if pos+(tl+8) > file_size or status=='c':
def read_index(file, name, index, vindex, tindex, stop='\377'*8, ltid=z64, start=4, maxoid=z64, recover=0): read=file.read seek=file.seek seek(0,2) file_size=file.tell() if file_size: if file_size < start: raise FileStorageFormatError, file.name seek(0) if read(4) != packed_version: raise FileStorageFormatError, name else: file.write(packed_version) return 4, maxoid, ltid index_get=index.get vndexpos=vindex.get tappend=tindex.append pos=start seek(start) unpack=struct.unpack tpos=0 tid='\0'*7+'\1' while 1: # Read the transaction record h=read(23) if not h: break if len(h) != 23: warn('%s truncated at %s', name, pos) seek(pos) file.truncate() break tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el if tid <= ltid: warn("%s time-stamp reduction at %s", name, pos) ltid=tid tl=u64(stl) if tl+pos+8 > file_size or status=='c': # Hm, the data were truncated or the checkpoint flag wasn't # cleared. They may also be corrupted, # in which case, we don't want to totally lose the data. warn("%s truncated, possibly due to damaged records at %s", name, pos) _truncate(file, name, pos) break if status not in ' up': warn('%s has invalid status, %s, at %s', name, status, pos) if ul > tl or dl > tl or el > tl or tl < (23+ul+dl+el): # We're in trouble. Find out if this is bad data in the # middle of the file, or just a turd that Win 9x dropped # at the end when the system crashed. # Skip to the end and read what should be the transaction length # of the last transaction. seek(-8, 2) rtl=u64(read(8)) # Now check to see if the redundant transaction length is # reasonable: if file_size - rtl < pos or rtl < 23: nearPanic('%s has invalid transaction header at %s', name, pos) warn("It appears that there is invalid data at the end of the " "file, possibly due to a system crash. %s truncated " "to recover from bad data at end." % name) _truncate(file, name, pos) break else: if recover: return tpos, None, None 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: if recover: return tpos, None, None 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)) 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: if recover: return tpos, None, None panic("%s data record exceeds transaction record at %s", name, pos) if index_get(oid,0) != prev: if prev: if recover: return tpos, None, None panic("%s incorrect previous pointer at %s", name, pos) else: warn("%s incorrect previous pointer at %s", name, pos) pos=pos+dlen if pos != tend: if recover: return tpos, None, None 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: if recover: return tpos, None, None 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
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
rtl=u64(read(8))
rtl=U64(read(8))
def read_index(file, name, index, vindex, tindex, stop='\377'*8, ltid=z64, start=4, maxoid=z64, recover=0): read=file.read seek=file.seek seek(0,2) file_size=file.tell() if file_size: if file_size < start: raise FileStorageFormatError, file.name seek(0) if read(4) != packed_version: raise FileStorageFormatError, name else: file.write(packed_version) return 4, maxoid, ltid index_get=index.get vndexpos=vindex.get tappend=tindex.append pos=start seek(start) unpack=struct.unpack tpos=0 tid='\0'*7+'\1' while 1: # Read the transaction record h=read(23) if not h: break if len(h) != 23: warn('%s truncated at %s', name, pos) seek(pos) file.truncate() break tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el if tid <= ltid: warn("%s time-stamp reduction at %s", name, pos) ltid=tid tl=u64(stl) if tl+pos+8 > file_size or status=='c': # Hm, the data were truncated or the checkpoint flag wasn't # cleared. They may also be corrupted, # in which case, we don't want to totally lose the data. warn("%s truncated, possibly due to damaged records at %s", name, pos) _truncate(file, name, pos) break if status not in ' up': warn('%s has invalid status, %s, at %s', name, status, pos) if ul > tl or dl > tl or el > tl or tl < (23+ul+dl+el): # We're in trouble. Find out if this is bad data in the # middle of the file, or just a turd that Win 9x dropped # at the end when the system crashed. # Skip to the end and read what should be the transaction length # of the last transaction. seek(-8, 2) rtl=u64(read(8)) # Now check to see if the redundant transaction length is # reasonable: if file_size - rtl < pos or rtl < 23: nearPanic('%s has invalid transaction header at %s', name, pos) warn("It appears that there is invalid data at the end of the " "file, possibly due to a system crash. %s truncated " "to recover from bad data at end." % name) _truncate(file, name, pos) break else: if recover: return tpos, None, None 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: if recover: return tpos, None, None 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)) 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: if recover: return tpos, None, None panic("%s data record exceeds transaction record at %s", name, pos) if index_get(oid,0) != prev: if prev: if recover: return tpos, None, None panic("%s incorrect previous pointer at %s", name, pos) else: warn("%s incorrect previous pointer at %s", name, pos) pos=pos+dlen if pos != tend: if recover: return tpos, None, None 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: if recover: return tpos, None, None 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
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
if recover: return tpos, None, None
if recover: return pos, None, None
def read_index(file, name, index, vindex, tindex, stop='\377'*8, ltid=z64, start=4, maxoid=z64, recover=0): read=file.read seek=file.seek seek(0,2) file_size=file.tell() if file_size: if file_size < start: raise FileStorageFormatError, file.name seek(0) if read(4) != packed_version: raise FileStorageFormatError, name else: file.write(packed_version) return 4, maxoid, ltid index_get=index.get vndexpos=vindex.get tappend=tindex.append pos=start seek(start) unpack=struct.unpack tpos=0 tid='\0'*7+'\1' while 1: # Read the transaction record h=read(23) if not h: break if len(h) != 23: warn('%s truncated at %s', name, pos) seek(pos) file.truncate() break tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el if tid <= ltid: warn("%s time-stamp reduction at %s", name, pos) ltid=tid tl=u64(stl) if tl+pos+8 > file_size or status=='c': # Hm, the data were truncated or the checkpoint flag wasn't # cleared. They may also be corrupted, # in which case, we don't want to totally lose the data. warn("%s truncated, possibly due to damaged records at %s", name, pos) _truncate(file, name, pos) break if status not in ' up': warn('%s has invalid status, %s, at %s', name, status, pos) if ul > tl or dl > tl or el > tl or tl < (23+ul+dl+el): # We're in trouble. Find out if this is bad data in the # middle of the file, or just a turd that Win 9x dropped # at the end when the system crashed. # Skip to the end and read what should be the transaction length # of the last transaction. seek(-8, 2) rtl=u64(read(8)) # Now check to see if the redundant transaction length is # reasonable: if file_size - rtl < pos or rtl < 23: nearPanic('%s has invalid transaction header at %s', name, pos) warn("It appears that there is invalid data at the end of the " "file, possibly due to a system crash. %s truncated " "to recover from bad data at end." % name) _truncate(file, name, pos) break else: if recover: return tpos, None, None 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: if recover: return tpos, None, None 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)) 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: if recover: return tpos, None, None panic("%s data record exceeds transaction record at %s", name, pos) if index_get(oid,0) != prev: if prev: if recover: return tpos, None, None panic("%s incorrect previous pointer at %s", name, pos) else: warn("%s incorrect previous pointer at %s", name, pos) pos=pos+dlen if pos != tend: if recover: return tpos, None, None 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: if recover: return tpos, None, None 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
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
pos=tpos+23+ul+dl+el
pos=tpos+(23+ul+dl+el)
def read_index(file, name, index, vindex, tindex, stop='\377'*8, ltid=z64, start=4, maxoid=z64, recover=0): read=file.read seek=file.seek seek(0,2) file_size=file.tell() if file_size: if file_size < start: raise FileStorageFormatError, file.name seek(0) if read(4) != packed_version: raise FileStorageFormatError, name else: file.write(packed_version) return 4, maxoid, ltid index_get=index.get vndexpos=vindex.get tappend=tindex.append pos=start seek(start) unpack=struct.unpack tpos=0 tid='\0'*7+'\1' while 1: # Read the transaction record h=read(23) if not h: break if len(h) != 23: warn('%s truncated at %s', name, pos) seek(pos) file.truncate() break tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el if tid <= ltid: warn("%s time-stamp reduction at %s", name, pos) ltid=tid tl=u64(stl) if tl+pos+8 > file_size or status=='c': # Hm, the data were truncated or the checkpoint flag wasn't # cleared. They may also be corrupted, # in which case, we don't want to totally lose the data. warn("%s truncated, possibly due to damaged records at %s", name, pos) _truncate(file, name, pos) break if status not in ' up': warn('%s has invalid status, %s, at %s', name, status, pos) if ul > tl or dl > tl or el > tl or tl < (23+ul+dl+el): # We're in trouble. Find out if this is bad data in the # middle of the file, or just a turd that Win 9x dropped # at the end when the system crashed. # Skip to the end and read what should be the transaction length # of the last transaction. seek(-8, 2) rtl=u64(read(8)) # Now check to see if the redundant transaction length is # reasonable: if file_size - rtl < pos or rtl < 23: nearPanic('%s has invalid transaction header at %s', name, pos) warn("It appears that there is invalid data at the end of the " "file, possibly due to a system crash. %s truncated " "to recover from bad data at end." % name) _truncate(file, name, pos) break else: if recover: return tpos, None, None 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: if recover: return tpos, None, None 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)) 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: if recover: return tpos, None, None panic("%s data record exceeds transaction record at %s", name, pos) if index_get(oid,0) != prev: if prev: if recover: return tpos, None, None panic("%s incorrect previous pointer at %s", name, pos) else: warn("%s incorrect previous pointer at %s", name, pos) pos=pos+dlen if pos != tend: if recover: return tpos, None, None 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: if recover: return tpos, None, None 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
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
prev=u64(sprev) tloc=u64(stloc) plen=u64(splen)
prev=U64(sprev) tloc=U64(stloc) plen=U64(splen)
def read_index(file, name, index, vindex, tindex, stop='\377'*8, ltid=z64, start=4, maxoid=z64, recover=0): read=file.read seek=file.seek seek(0,2) file_size=file.tell() if file_size: if file_size < start: raise FileStorageFormatError, file.name seek(0) if read(4) != packed_version: raise FileStorageFormatError, name else: file.write(packed_version) return 4, maxoid, ltid index_get=index.get vndexpos=vindex.get tappend=tindex.append pos=start seek(start) unpack=struct.unpack tpos=0 tid='\0'*7+'\1' while 1: # Read the transaction record h=read(23) if not h: break if len(h) != 23: warn('%s truncated at %s', name, pos) seek(pos) file.truncate() break tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el if tid <= ltid: warn("%s time-stamp reduction at %s", name, pos) ltid=tid tl=u64(stl) if tl+pos+8 > file_size or status=='c': # Hm, the data were truncated or the checkpoint flag wasn't # cleared. They may also be corrupted, # in which case, we don't want to totally lose the data. warn("%s truncated, possibly due to damaged records at %s", name, pos) _truncate(file, name, pos) break if status not in ' up': warn('%s has invalid status, %s, at %s', name, status, pos) if ul > tl or dl > tl or el > tl or tl < (23+ul+dl+el): # We're in trouble. Find out if this is bad data in the # middle of the file, or just a turd that Win 9x dropped # at the end when the system crashed. # Skip to the end and read what should be the transaction length # of the last transaction. seek(-8, 2) rtl=u64(read(8)) # Now check to see if the redundant transaction length is # reasonable: if file_size - rtl < pos or rtl < 23: nearPanic('%s has invalid transaction header at %s', name, pos) warn("It appears that there is invalid data at the end of the " "file, possibly due to a system crash. %s truncated " "to recover from bad data at end." % name) _truncate(file, name, pos) break else: if recover: return tpos, None, None 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: if recover: return tpos, None, None 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)) 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: if recover: return tpos, None, None panic("%s data record exceeds transaction record at %s", name, pos) if index_get(oid,0) != prev: if prev: if recover: return tpos, None, None panic("%s incorrect previous pointer at %s", name, pos) else: warn("%s incorrect previous pointer at %s", name, pos) pos=pos+dlen if pos != tend: if recover: return tpos, None, None 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: if recover: return tpos, None, None 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
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
dlen=dlen+16+vlen
dlen=dlen+(16+vlen)
def read_index(file, name, index, vindex, tindex, stop='\377'*8, ltid=z64, start=4, maxoid=z64, recover=0): read=file.read seek=file.seek seek(0,2) file_size=file.tell() if file_size: if file_size < start: raise FileStorageFormatError, file.name seek(0) if read(4) != packed_version: raise FileStorageFormatError, name else: file.write(packed_version) return 4, maxoid, ltid index_get=index.get vndexpos=vindex.get tappend=tindex.append pos=start seek(start) unpack=struct.unpack tpos=0 tid='\0'*7+'\1' while 1: # Read the transaction record h=read(23) if not h: break if len(h) != 23: warn('%s truncated at %s', name, pos) seek(pos) file.truncate() break tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el if tid <= ltid: warn("%s time-stamp reduction at %s", name, pos) ltid=tid tl=u64(stl) if tl+pos+8 > file_size or status=='c': # Hm, the data were truncated or the checkpoint flag wasn't # cleared. They may also be corrupted, # in which case, we don't want to totally lose the data. warn("%s truncated, possibly due to damaged records at %s", name, pos) _truncate(file, name, pos) break if status not in ' up': warn('%s has invalid status, %s, at %s', name, status, pos) if ul > tl or dl > tl or el > tl or tl < (23+ul+dl+el): # We're in trouble. Find out if this is bad data in the # middle of the file, or just a turd that Win 9x dropped # at the end when the system crashed. # Skip to the end and read what should be the transaction length # of the last transaction. seek(-8, 2) rtl=u64(read(8)) # Now check to see if the redundant transaction length is # reasonable: if file_size - rtl < pos or rtl < 23: nearPanic('%s has invalid transaction header at %s', name, pos) warn("It appears that there is invalid data at the end of the " "file, possibly due to a system crash. %s truncated " "to recover from bad data at end." % name) _truncate(file, name, pos) break else: if recover: return tpos, None, None 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: if recover: return tpos, None, None 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)) 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: if recover: return tpos, None, None panic("%s data record exceeds transaction record at %s", name, pos) if index_get(oid,0) != prev: if prev: if recover: return tpos, None, None panic("%s incorrect previous pointer at %s", name, pos) else: warn("%s incorrect previous pointer at %s", name, pos) pos=pos+dlen if pos != tend: if recover: return tpos, None, None 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: if recover: return tpos, None, None 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
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
pv=u64(read(8))
pv=U64(read(8))
def read_index(file, name, index, vindex, tindex, stop='\377'*8, ltid=z64, start=4, maxoid=z64, recover=0): read=file.read seek=file.seek seek(0,2) file_size=file.tell() if file_size: if file_size < start: raise FileStorageFormatError, file.name seek(0) if read(4) != packed_version: raise FileStorageFormatError, name else: file.write(packed_version) return 4, maxoid, ltid index_get=index.get vndexpos=vindex.get tappend=tindex.append pos=start seek(start) unpack=struct.unpack tpos=0 tid='\0'*7+'\1' while 1: # Read the transaction record h=read(23) if not h: break if len(h) != 23: warn('%s truncated at %s', name, pos) seek(pos) file.truncate() break tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el if tid <= ltid: warn("%s time-stamp reduction at %s", name, pos) ltid=tid tl=u64(stl) if tl+pos+8 > file_size or status=='c': # Hm, the data were truncated or the checkpoint flag wasn't # cleared. They may also be corrupted, # in which case, we don't want to totally lose the data. warn("%s truncated, possibly due to damaged records at %s", name, pos) _truncate(file, name, pos) break if status not in ' up': warn('%s has invalid status, %s, at %s', name, status, pos) if ul > tl or dl > tl or el > tl or tl < (23+ul+dl+el): # We're in trouble. Find out if this is bad data in the # middle of the file, or just a turd that Win 9x dropped # at the end when the system crashed. # Skip to the end and read what should be the transaction length # of the last transaction. seek(-8, 2) rtl=u64(read(8)) # Now check to see if the redundant transaction length is # reasonable: if file_size - rtl < pos or rtl < 23: nearPanic('%s has invalid transaction header at %s', name, pos) warn("It appears that there is invalid data at the end of the " "file, possibly due to a system crash. %s truncated " "to recover from bad data at end." % name) _truncate(file, name, pos) break else: if recover: return tpos, None, None 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: if recover: return tpos, None, None 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)) 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: if recover: return tpos, None, None panic("%s data record exceeds transaction record at %s", name, pos) if index_get(oid,0) != prev: if prev: if recover: return tpos, None, None panic("%s incorrect previous pointer at %s", name, pos) else: warn("%s incorrect previous pointer at %s", name, pos) pos=pos+dlen if pos != tend: if recover: return tpos, None, None 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: if recover: return tpos, None, None 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
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
old=u64(back)
old=U64(back)
def _loadBack(file, oid, back): seek=file.seek read=file.read while 1: old=u64(back) if not old: raise KeyError, oid seek(old) h=read(42) doid,serial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h) if vlen: seek(vlen+16,1) if plen != z64: return read(u64(plen)), serial back=read(8) # We got a back pointer!
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
if plen != z64: return read(u64(plen)), serial
if plen != z64: return read(U64(plen)), serial
def _loadBack(file, oid, back): seek=file.seek read=file.read while 1: old=u64(back) if not old: raise KeyError, oid seek(old) h=read(42) doid,serial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h) if vlen: seek(vlen+16,1) if plen != z64: return read(u64(plen)), serial back=read(8) # We got a back pointer!
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
old=u64(back)
old=U64(back)
def _loadBackPOS(file, oid, back): seek=file.seek read=file.read while 1: old=u64(back) if not old: raise KeyError, oid seek(old) h=read(42) doid,serial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h) if vlen: seek(vlen+16,1) if plen != z64: return old back=read(8) # We got a back pointer!
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
self._pos=4
self._pos=4L
def __init__(self, file): if type(file) is type(''): file=open(file, 'r+b') self._file=file if file.read(4) != packed_version: raise FileStorageFormatError, name file.seek(0,2) self._file_size=file.tell() self._pos=4
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
tl=u64(stl) if tl+pos+8 > self._file_size or status=='c':
tl=U64(stl) if pos+(tl+8) > self._file_size or status=='c':
def next(self, index=0): file=self._file seek=file.seek read=file.read pos=self._pos
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
def next(self, index=0): file=self._file seek=file.seek read=file.read pos=self._pos
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
rtl=u64(read(8))
rtl=U64(read(8))
def next(self, index=0): file=self._file seek=file.seek read=file.read pos=self._pos
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
warn("It appears that there is invalid data at the end of the " "file, possibly due to a system crash. %s truncated " "to recover from bad data at end."
warn("It appears that there is invalid data at the end of " "the file, possibly due to a system crash. %s " "truncated to recover from bad data at end."
def next(self, index=0): file=self._file seek=file.seek read=file.read pos=self._pos
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
pos=tpos+23+ul+dl+el
pos=tpos+(23+ul+dl+el)
def next(self, index=0): file=self._file seek=file.seek read=file.read pos=self._pos
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
prev=u64(sprev) tloc=u64(stloc) plen=u64(splen)
prev=U64(sprev) tloc=U64(stloc) plen=U64(splen)
def next(self, index=0): name='' pos = self._pos tend, file, seek, read, tpos = self._stuff while pos < tend: # Read the data records for this transaction
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
dlen=dlen+16+vlen
dlen=dlen+(16+vlen)
def next(self, index=0): name='' pos = self._pos tend, file, seek, read, tpos = self._stuff while pos < tend: # Read the data records for this transaction
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
pv=u64(read(8))
pv=U64(read(8))
def next(self, index=0): name='' pos = self._pos tend, file, seek, read, tpos = self._stuff while pos < tend: # Read the data records for this transaction
e9aa3bd398cba329c8a421eb6d47f4dba6e400a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/e9aa3bd398cba329c8a421eb6d47f4dba6e400a9/FileStorage.py
log("wait() async=%d" % self.is_async(), level=zLOG.TRACE)
log("wait(%d), async=%d" % (msgid, self.is_async()), level=zLOG.TRACE)
def wait(self, msgid): """Invoke asyncore mainloop and wait for reply.""" if __debug__: log("wait() async=%d" % self.is_async(), level=zLOG.TRACE) if self.is_async(): self.trigger.pull_trigger()
8cba505590688054372b55b2e09e37ee054879c5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/8cba505590688054372b55b2e09e37ee054879c5/connection.py
asyncore.poll(10.0, self._map)
if __debug__: log("wait(%d): asyncore.poll(%s)" % (msgid, delay), level=zLOG.TRACE) asyncore.poll(delay, self._map) if delay < 1.0: delay += delay
def wait(self, msgid): """Invoke asyncore mainloop and wait for reply.""" if __debug__: log("wait() async=%d" % self.is_async(), level=zLOG.TRACE) if self.is_async(): self.trigger.pull_trigger()
8cba505590688054372b55b2e09e37ee054879c5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/8cba505590688054372b55b2e09e37ee054879c5/connection.py
def testItemsNegativeIndex(self): L = [-3, 6, -11, 4] for i in L: self.t[i] = i L.sort() items = self.t.items() for i in range(-1, -4, -1): self.assertEqual(items[i], (L[i], L[i])) self.assertRaises(IndexError, lambda: items[-5])
def testItemsWorks(self): for x in range(100): self.t[x] = 2*x v = self.t.items() i = 0 for x in v: self.assertEqual(x[0], i) self.assertEqual(x[1], 2*i) i += 1
b4ae0a53abf9984d8b2f9327eb9b84ff5e5717da /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/b4ae0a53abf9984d8b2f9327eb9b84ff5e5717da/testBTrees.py
zLOG.LOG(label or _label, level, message, error=error)
label = label or _label if LOG_THREAD_ID: label = "%s:%s" % (label, threading.currentThread().getName()) zLOG.LOG(label, level, message, error=error)
def log(message, level=zLOG.BLATHER, label=None, error=None): zLOG.LOG(label or _label, level, message, error=error)
b3c871b25737cbea7b058b724774e748319b8604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/b3c871b25737cbea7b058b724774e748319b8604/log.py
return
def checkSize(self): # XXX need to fix return self.assertEqual(self.db.cacheSize(), 0) self.assertEqual(self.db.cacheDetailSize(), [])
069ef5f3c7632edb828d987ae21e4bf5535b0fdb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/069ef5f3c7632edb828d987ae21e4bf5535b0fdb/testCache.py
self.assertEquals(self.db.cacheSize(), CACHE_SIZE * CONNS) details = self.db.cacheDetailSize() self.assertEquals(len(details), CONNS) for d in details: self.assertEquals(d['ngsize'], CACHE_SIZE) self.assertEquals(d['size'], CACHE_SIZE + 1)
self.assertEquals(self.db.cacheSize(), 0)
def checkSize(self): # XXX need to fix return self.assertEqual(self.db.cacheSize(), 0) self.assertEqual(self.db.cacheDetailSize(), [])
069ef5f3c7632edb828d987ae21e4bf5535b0fdb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/069ef5f3c7632edb828d987ae21e4bf5535b0fdb/testCache.py
return
def checkDetail(self): # XXX need to fix return CACHE_SIZE = 10 self.db.setCacheSize(CACHE_SIZE)
069ef5f3c7632edb828d987ae21e4bf5535b0fdb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/069ef5f3c7632edb828d987ae21e4bf5535b0fdb/testCache.py
for klass, count in self.db.cacheDetail(): print klass, count if klass.endswith('MinPO'): self.assertEqual(count, CONNS * CACHE_SIZE) if klass.endswith('PersistentMapping'): self.assertEqual(count, CONNS)
[(klass, count)] = self.db.cacheDetail() self.assertEqual(klass, "Persistence.PersistentMapping") self.assertEqual(count, CONNS)
def checkDetail(self): # XXX need to fix return CACHE_SIZE = 10 self.db.setCacheSize(CACHE_SIZE)
069ef5f3c7632edb828d987ae21e4bf5535b0fdb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/069ef5f3c7632edb828d987ae21e4bf5535b0fdb/testCache.py
print details if details['klass'].endswith('PersistentMapping'): self.assertEqual(details['state'], None) else: self.assert_(details['klass'].endswith('MinPO')) self.assertEqual(details['state'], 0)
self.assertEqual(details["klass"], "Persistence.PersistentMapping") self.assertEqual(details['state'], None)
def checkDetail(self): # XXX need to fix return CACHE_SIZE = 10 self.db.setCacheSize(CACHE_SIZE)
069ef5f3c7632edb828d987ae21e4bf5535b0fdb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/069ef5f3c7632edb828d987ae21e4bf5535b0fdb/testCache.py
'r': (self._commit_lock_release, 0),
'U': (self._commit_lock_release, 0),
def out_of_band_hook( code, args, get_hook={ 'b': (invalidator.begin, 0), 'i': (invalidator.invalidate, 1), 'e': (invalidator.end, 0), 'I': (invalidator.Invalidate, 1), 'r': (self._commit_lock_release, 0), 's': (self._serials.append, 1), 'S': (self._info.update, 1), }.get):
4a43e943716c5499ee5e2bc8a6b74152d44467c7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/4a43e943716c5499ee5e2bc8a6b74152d44467c7/ClientStorage.py
return unittest.makeSuite(StorageTestCase)
suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(StorageTestCase)) import BDBStorage if BDBStorage.is_available: suite.addTest(unittest.makeSuite(BDBStorageTests)) return suite
def test_suite(): return unittest.makeSuite(StorageTestCase)
f784f9a84ebabfece0d07cee097ebbe940cdbbae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/f784f9a84ebabfece0d07cee097ebbe940cdbbae/testStorageConfig.py
test_merge(base, b1, b2, bm, 'empty one and not other')
test_merge(base, b1, b2, bm, 'empty one and not other', should_fail=1)
def testMergeEmpty(self): base, b1, b2, bm, e1, e2, items = self._setupConflict()
d52b5766355fd097c24bb77e6d6dc916db8bd138 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/d52b5766355fd097c24bb77e6d6dc916db8bd138/testConflict.py
test_merge(base, b1, b2, bm, 'empty one and not other')
test_merge(base, b1, b2, bm, 'empty one and not other', should_fail=1)
def testMergeEmpty(self): base, b1, b2, bm, e1, e2, items = self._setupConflict()
d52b5766355fd097c24bb77e6d6dc916db8bd138 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/d52b5766355fd097c24bb77e6d6dc916db8bd138/testConflict.py
get_transaction().commit() self.assertRaises(AssertionError, b._check)
self.assertRaises(ConflictError, get_transaction().commit) get_transaction().abort()
def testEmptyBucketConflict(self): # Tests that an emptied bucket *created by* conflict resolution is # viewed as a conflict: conflict resolution doesn't have enough # info to unlink the empty bucket from the BTree correctly. b = self.t for i in range(0, 200, 4): b[i] = i # bucket 0 has 15 values: 0, 4 .. 56 # bucket 1 has 15 values: 60, 64 .. 116 # bucket 2 has 20 values: 120, 124 .. 196 state = b.__getstate__() # Looks like: ((bucket0, 60, bucket1, 120, bucket2), firstbucket) # If these fail, the *preconditions* for running the test aren't # satisfied -- the test itself hasn't been run yet. self.assertEqual(len(state), 2) self.assertEqual(len(state[0]), 5) self.assertEqual(state[0][1], 60) self.assertEqual(state[0][3], 120)
d52b5766355fd097c24bb77e6d6dc916db8bd138 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/d52b5766355fd097c24bb77e6d6dc916db8bd138/testConflict.py
"phase commmit")
"phase commit")
def _finishCommit(self, txn): self.logger.debug("%s: commit", txn) try: for r in txn._resources: r.commit(txn) txn._status = Status.COMMITTED except: # An error occured during the second phase of 2PC. We can # no longer guarantee the system is in a consistent state. # The best we can do is abort() all the resource managers # that haven't already committed and hope for the best. error = sys.exc_info() txn._status = Status.FAILED self.abort(txn) msg = ("Transaction failed during second phase of two-" "phase commmit") self.logger.critical(msg, exc_info=error) raise TransactionError("Transaction failed during second " "phase of two-phase commit")
2b55027b0cc5584dcab4195dbf1d643da4c46df1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/2b55027b0cc5584dcab4195dbf1d643da4c46df1/manager.py
raise TransactionError("Transaction failed during second " "phase of two-phase commit")
raise TransactionError(msg)
def _finishCommit(self, txn): self.logger.debug("%s: commit", txn) try: for r in txn._resources: r.commit(txn) txn._status = Status.COMMITTED except: # An error occured during the second phase of 2PC. We can # no longer guarantee the system is in a consistent state. # The best we can do is abort() all the resource managers # that haven't already committed and hope for the best. error = sys.exc_info() txn._status = Status.FAILED self.abort(txn) msg = ("Transaction failed during second phase of two-" "phase commmit") self.logger.critical(msg, exc_info=error) raise TransactionError("Transaction failed during second " "phase of two-phase commit")
2b55027b0cc5584dcab4195dbf1d643da4c46df1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/2b55027b0cc5584dcab4195dbf1d643da4c46df1/manager.py
def checkLoadSerial(self): oid = self._storage.new_oid() revid = ZERO revisions = {} for i in range(31, 38): revid = self._dostore(oid, revid=revid, data=MinPO(i)) revisions[revid] = MinPO(i) # Now make sure all the revisions have the correct value for revid, value in revisions.items(): data = self._storage.loadSerial(oid, revid) assert zodb_unpickle(data) == value
fce53a9aff34fdd8b1985b1d63f410371e52b815 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/fce53a9aff34fdd8b1985b1d63f410371e52b815/BasicStorage.py
LOG("ZODB FS", BLATHER, "next(%d)" % index)
def next(self, index=0): if self._file is None: # A closed iterator. XXX: Is IOError the best we can do? For # now, mimic a read on a closed file. raise IOError, 'iterator is closed' file=self._file seek=file.seek read=file.read pos=self._pos
0f0899719267f94787a4dabe8ca2adfe326f5f14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/0f0899719267f94787a4dabe8ca2adfe326f5f14/FileStorage.py
if self._stop is not None: LOG("ZODB FS", BLATHER, ("tid %x > stop %x ? %d" % (U64(tid), U64(self._stop), tid > self._stop)))
def next(self, index=0): if self._file is None: # A closed iterator. XXX: Is IOError the best we can do? For # now, mimic a read on a closed file. raise IOError, 'iterator is closed' file=self._file seek=file.seek read=file.read pos=self._pos
0f0899719267f94787a4dabe8ca2adfe326f5f14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/0f0899719267f94787a4dabe8ca2adfe326f5f14/FileStorage.py
self.description = "%s\n\n%s" % (self.description, test.strip())
self.description = "%s\n\n%s" % (self.description, text.strip())
def note(self, text): if self.description: self.description = "%s\n\n%s" % (self.description, test.strip()) else: self.description = text.strip()
bf2e68092a2883a167d3d329f9b3cfb62ec44759 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/bf2e68092a2883a167d3d329f9b3cfb62ec44759/Transaction.py
def resume(self, txn): if self._current is not None: raise TransactionError("Can't resume while other " "transaction is active") self._suspended.remove(txn) self._current = txn
d75a3239c0321f93985e4d3bf301222339db156c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/d75a3239c0321f93985e4d3bf301222339db156c/manager.py
elif err[0] == 0: break
def pending(self): """Invoke mainloop until any pending messages are handled.""" if __debug__: log("pending(), async=%d" % self.is_async(), level=zLOG.TRACE) if self.is_async(): return # Inline the asyncore poll() function to know whether any input # was actually read. Repeat until no input is ready. # XXX This only does reads. r_in = [self._fileno] w_in = [] x_in = [] while 1: try: r, w, x = select.select(r_in, w_in, x_in, 0) except select.error, err: if err[0] == errno.EINTR: continue elif err[0] == 0: # Windows sez: "Error: Success." :-) break else: raise if not r: break try: self.handle_read_event() except asyncore.ExitNow: raise else: self.handle_error()
ddf9f94aa56510b4202ad686728b222b38b51667 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/ddf9f94aa56510b4202ad686728b222b38b51667/connection.py
else:
except:
def pending(self): """Invoke mainloop until any pending messages are handled.""" if __debug__: log("pending(), async=%d" % self.is_async(), level=zLOG.TRACE) if self.is_async(): return # Inline the asyncore poll() function to know whether any input # was actually read. Repeat until no input is ready. # XXX This only does reads. r_in = [self._fileno] w_in = [] x_in = [] while 1: try: r, w, x = select.select(r_in, w_in, x_in, 0) except select.error, err: if err[0] == errno.EINTR: continue elif err[0] == 0: # Windows sez: "Error: Success." :-) break else: raise if not r: break try: self.handle_read_event() except asyncore.ExitNow: raise else: self.handle_error()
ddf9f94aa56510b4202ad686728b222b38b51667 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/ddf9f94aa56510b4202ad686728b222b38b51667/connection.py
def read_transaction_header(file, pos, file_size):
def read_txn_header(f, pos, file_size, outp, ltid):
def read_transaction_header(file, pos, file_size): # Read the transaction record file.seek(pos) h = file.read(23) if len(h) < 23: raise EOFError tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el tl=u64(stl) if status=='c': raise EOFError if pos+(tl+8) > file_size: error("bad transaction length at %s", pos) if status not in ' up': error('invalid status, %s, at %s', status, pos) if tl < (23+ul+dl+el): error('invalid transaction length, %s, at %s', tl, pos) tpos=pos tend=tpos+tl if status=='u': # Undone transaction, skip it file.seek(tend) h = file.read(8) if h != stl: error('inconsistent transaction length at %s', pos) pos = tend + 8 return pos, None pos = tpos+(23+ul+dl+el) user = file.read(ul) description = file.read(dl) if el: try: e=loads(file.read(el)) except: e={} else: e={} result = RecordIterator(tid, status, user, description, e, pos, tend, file, tpos) pos=tend # Read the (intentionally redundant) transaction length file.seek(pos) h = file.read(8) if h != stl: error("redundant transaction length check failed at %s", pos) pos += 8 return pos, result
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
file.seek(pos) h = file.read(23)
f.seek(pos) h = f.read(23)
def read_transaction_header(file, pos, file_size): # Read the transaction record file.seek(pos) h = file.read(23) if len(h) < 23: raise EOFError tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el tl=u64(stl) if status=='c': raise EOFError if pos+(tl+8) > file_size: error("bad transaction length at %s", pos) if status not in ' up': error('invalid status, %s, at %s', status, pos) if tl < (23+ul+dl+el): error('invalid transaction length, %s, at %s', tl, pos) tpos=pos tend=tpos+tl if status=='u': # Undone transaction, skip it file.seek(tend) h = file.read(8) if h != stl: error('inconsistent transaction length at %s', pos) pos = tend + 8 return pos, None pos = tpos+(23+ul+dl+el) user = file.read(ul) description = file.read(dl) if el: try: e=loads(file.read(el)) except: e={} else: e={} result = RecordIterator(tid, status, user, description, e, pos, tend, file, tpos) pos=tend # Read the (intentionally redundant) transaction length file.seek(pos) h = file.read(8) if h != stl: error("redundant transaction length check failed at %s", pos) pos += 8 return pos, result
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
tl=u64(stl) if status=='c': raise EOFError if pos+(tl+8) > file_size:
tl = u64(stl) if pos + (tl + 8) > file_size:
def read_transaction_header(file, pos, file_size): # Read the transaction record file.seek(pos) h = file.read(23) if len(h) < 23: raise EOFError tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el tl=u64(stl) if status=='c': raise EOFError if pos+(tl+8) > file_size: error("bad transaction length at %s", pos) if status not in ' up': error('invalid status, %s, at %s', status, pos) if tl < (23+ul+dl+el): error('invalid transaction length, %s, at %s', tl, pos) tpos=pos tend=tpos+tl if status=='u': # Undone transaction, skip it file.seek(tend) h = file.read(8) if h != stl: error('inconsistent transaction length at %s', pos) pos = tend + 8 return pos, None pos = tpos+(23+ul+dl+el) user = file.read(ul) description = file.read(dl) if el: try: e=loads(file.read(el)) except: e={} else: e={} result = RecordIterator(tid, status, user, description, e, pos, tend, file, tpos) pos=tend # Read the (intentionally redundant) transaction length file.seek(pos) h = file.read(8) if h != stl: error("redundant transaction length check failed at %s", pos) pos += 8 return pos, result
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
if status not in ' up': error('invalid status, %s, at %s', status, pos) if tl < (23+ul+dl+el): error('invalid transaction length, %s, at %s', tl, pos) tpos=pos tend=tpos+tl if status=='u':
if tl < (23 + ul + dl + el): error("invalid transaction length, %s, at %s", tl, pos) if ltid and tid < ltid: error("time-stamp reducation %s < %s, at %s", u64(tid), u64(ltid), pos) if status == "c": truncate(f, pos, file_size, output) raise EOFError if status not in " up": error("invalid status, %r, at %s", status, pos) tpos = pos tend = tpos + tl if status == "u":
def read_transaction_header(file, pos, file_size): # Read the transaction record file.seek(pos) h = file.read(23) if len(h) < 23: raise EOFError tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el tl=u64(stl) if status=='c': raise EOFError if pos+(tl+8) > file_size: error("bad transaction length at %s", pos) if status not in ' up': error('invalid status, %s, at %s', status, pos) if tl < (23+ul+dl+el): error('invalid transaction length, %s, at %s', tl, pos) tpos=pos tend=tpos+tl if status=='u': # Undone transaction, skip it file.seek(tend) h = file.read(8) if h != stl: error('inconsistent transaction length at %s', pos) pos = tend + 8 return pos, None pos = tpos+(23+ul+dl+el) user = file.read(ul) description = file.read(dl) if el: try: e=loads(file.read(el)) except: e={} else: e={} result = RecordIterator(tid, status, user, description, e, pos, tend, file, tpos) pos=tend # Read the (intentionally redundant) transaction length file.seek(pos) h = file.read(8) if h != stl: error("redundant transaction length check failed at %s", pos) pos += 8 return pos, result
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
file.seek(tend) h = file.read(8)
f.seek(tend) h = f.read(8)
def read_transaction_header(file, pos, file_size): # Read the transaction record file.seek(pos) h = file.read(23) if len(h) < 23: raise EOFError tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el tl=u64(stl) if status=='c': raise EOFError if pos+(tl+8) > file_size: error("bad transaction length at %s", pos) if status not in ' up': error('invalid status, %s, at %s', status, pos) if tl < (23+ul+dl+el): error('invalid transaction length, %s, at %s', tl, pos) tpos=pos tend=tpos+tl if status=='u': # Undone transaction, skip it file.seek(tend) h = file.read(8) if h != stl: error('inconsistent transaction length at %s', pos) pos = tend + 8 return pos, None pos = tpos+(23+ul+dl+el) user = file.read(ul) description = file.read(dl) if el: try: e=loads(file.read(el)) except: e={} else: e={} result = RecordIterator(tid, status, user, description, e, pos, tend, file, tpos) pos=tend # Read the (intentionally redundant) transaction length file.seek(pos) h = file.read(8) if h != stl: error("redundant transaction length check failed at %s", pos) pos += 8 return pos, result
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
error('inconsistent transaction length at %s', pos)
error("inconsistent transaction length at %s", pos)
def read_transaction_header(file, pos, file_size): # Read the transaction record file.seek(pos) h = file.read(23) if len(h) < 23: raise EOFError tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el tl=u64(stl) if status=='c': raise EOFError if pos+(tl+8) > file_size: error("bad transaction length at %s", pos) if status not in ' up': error('invalid status, %s, at %s', status, pos) if tl < (23+ul+dl+el): error('invalid transaction length, %s, at %s', tl, pos) tpos=pos tend=tpos+tl if status=='u': # Undone transaction, skip it file.seek(tend) h = file.read(8) if h != stl: error('inconsistent transaction length at %s', pos) pos = tend + 8 return pos, None pos = tpos+(23+ul+dl+el) user = file.read(ul) description = file.read(dl) if el: try: e=loads(file.read(el)) except: e={} else: e={} result = RecordIterator(tid, status, user, description, e, pos, tend, file, tpos) pos=tend # Read the (intentionally redundant) transaction length file.seek(pos) h = file.read(8) if h != stl: error("redundant transaction length check failed at %s", pos) pos += 8 return pos, result
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
return pos, None
return pos, None, tid
def read_transaction_header(file, pos, file_size): # Read the transaction record file.seek(pos) h = file.read(23) if len(h) < 23: raise EOFError tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el tl=u64(stl) if status=='c': raise EOFError if pos+(tl+8) > file_size: error("bad transaction length at %s", pos) if status not in ' up': error('invalid status, %s, at %s', status, pos) if tl < (23+ul+dl+el): error('invalid transaction length, %s, at %s', tl, pos) tpos=pos tend=tpos+tl if status=='u': # Undone transaction, skip it file.seek(tend) h = file.read(8) if h != stl: error('inconsistent transaction length at %s', pos) pos = tend + 8 return pos, None pos = tpos+(23+ul+dl+el) user = file.read(ul) description = file.read(dl) if el: try: e=loads(file.read(el)) except: e={} else: e={} result = RecordIterator(tid, status, user, description, e, pos, tend, file, tpos) pos=tend # Read the (intentionally redundant) transaction length file.seek(pos) h = file.read(8) if h != stl: error("redundant transaction length check failed at %s", pos) pos += 8 return pos, result
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
user = file.read(ul) description = file.read(dl)
user = f.read(ul) description = f.read(dl)
def read_transaction_header(file, pos, file_size): # Read the transaction record file.seek(pos) h = file.read(23) if len(h) < 23: raise EOFError tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el tl=u64(stl) if status=='c': raise EOFError if pos+(tl+8) > file_size: error("bad transaction length at %s", pos) if status not in ' up': error('invalid status, %s, at %s', status, pos) if tl < (23+ul+dl+el): error('invalid transaction length, %s, at %s', tl, pos) tpos=pos tend=tpos+tl if status=='u': # Undone transaction, skip it file.seek(tend) h = file.read(8) if h != stl: error('inconsistent transaction length at %s', pos) pos = tend + 8 return pos, None pos = tpos+(23+ul+dl+el) user = file.read(ul) description = file.read(dl) if el: try: e=loads(file.read(el)) except: e={} else: e={} result = RecordIterator(tid, status, user, description, e, pos, tend, file, tpos) pos=tend # Read the (intentionally redundant) transaction length file.seek(pos) h = file.read(8) if h != stl: error("redundant transaction length check failed at %s", pos) pos += 8 return pos, result
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
try: e=loads(file.read(el))
try: e=loads(f.read(el))
def read_transaction_header(file, pos, file_size): # Read the transaction record file.seek(pos) h = file.read(23) if len(h) < 23: raise EOFError tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el tl=u64(stl) if status=='c': raise EOFError if pos+(tl+8) > file_size: error("bad transaction length at %s", pos) if status not in ' up': error('invalid status, %s, at %s', status, pos) if tl < (23+ul+dl+el): error('invalid transaction length, %s, at %s', tl, pos) tpos=pos tend=tpos+tl if status=='u': # Undone transaction, skip it file.seek(tend) h = file.read(8) if h != stl: error('inconsistent transaction length at %s', pos) pos = tend + 8 return pos, None pos = tpos+(23+ul+dl+el) user = file.read(ul) description = file.read(dl) if el: try: e=loads(file.read(el)) except: e={} else: e={} result = RecordIterator(tid, status, user, description, e, pos, tend, file, tpos) pos=tend # Read the (intentionally redundant) transaction length file.seek(pos) h = file.read(8) if h != stl: error("redundant transaction length check failed at %s", pos) pos += 8 return pos, result
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
file, tpos) pos=tend
f, tpos) pos = tend
def read_transaction_header(file, pos, file_size): # Read the transaction record file.seek(pos) h = file.read(23) if len(h) < 23: raise EOFError tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el tl=u64(stl) if status=='c': raise EOFError if pos+(tl+8) > file_size: error("bad transaction length at %s", pos) if status not in ' up': error('invalid status, %s, at %s', status, pos) if tl < (23+ul+dl+el): error('invalid transaction length, %s, at %s', tl, pos) tpos=pos tend=tpos+tl if status=='u': # Undone transaction, skip it file.seek(tend) h = file.read(8) if h != stl: error('inconsistent transaction length at %s', pos) pos = tend + 8 return pos, None pos = tpos+(23+ul+dl+el) user = file.read(ul) description = file.read(dl) if el: try: e=loads(file.read(el)) except: e={} else: e={} result = RecordIterator(tid, status, user, description, e, pos, tend, file, tpos) pos=tend # Read the (intentionally redundant) transaction length file.seek(pos) h = file.read(8) if h != stl: error("redundant transaction length check failed at %s", pos) pos += 8 return pos, result
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
file.seek(pos) h = file.read(8)
f.seek(pos) h = f.read(8)
def read_transaction_header(file, pos, file_size): # Read the transaction record file.seek(pos) h = file.read(23) if len(h) < 23: raise EOFError tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el tl=u64(stl) if status=='c': raise EOFError if pos+(tl+8) > file_size: error("bad transaction length at %s", pos) if status not in ' up': error('invalid status, %s, at %s', status, pos) if tl < (23+ul+dl+el): error('invalid transaction length, %s, at %s', tl, pos) tpos=pos tend=tpos+tl if status=='u': # Undone transaction, skip it file.seek(tend) h = file.read(8) if h != stl: error('inconsistent transaction length at %s', pos) pos = tend + 8 return pos, None pos = tpos+(23+ul+dl+el) user = file.read(ul) description = file.read(dl) if el: try: e=loads(file.read(el)) except: e={} else: e={} result = RecordIterator(tid, status, user, description, e, pos, tend, file, tpos) pos=tend # Read the (intentionally redundant) transaction length file.seek(pos) h = file.read(8) if h != stl: error("redundant transaction length check failed at %s", pos) pos += 8 return pos, result
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
return pos, result def scan(file, pos): """Return a potential transaction location following pos in file.
return pos, result, tid def truncate(f, pos, file_size, outp): """Copy data from pos to end of f to a .trNNN file.""" i = 0 while 1: trname = outp + ".tr%d" % i if os.path.exists(trname): i += 1 tr = open(trname, "wb") copy(f, tr, file_size - pos) f.seek(pos) tr.close() def copy(src, dst, n): while n: buf = src.read(8096) if not buf: break if len(buf) > n: buf = buf[:n] dst.write(buf) n -= len(buf) def scan(f, pos): """Return a potential transaction location following pos in f.
def read_transaction_header(file, pos, file_size): # Read the transaction record file.seek(pos) h = file.read(23) if len(h) < 23: raise EOFError tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el tl=u64(stl) if status=='c': raise EOFError if pos+(tl+8) > file_size: error("bad transaction length at %s", pos) if status not in ' up': error('invalid status, %s, at %s', status, pos) if tl < (23+ul+dl+el): error('invalid transaction length, %s, at %s', tl, pos) tpos=pos tend=tpos+tl if status=='u': # Undone transaction, skip it file.seek(tend) h = file.read(8) if h != stl: error('inconsistent transaction length at %s', pos) pos = tend + 8 return pos, None pos = tpos+(23+ul+dl+el) user = file.read(ul) description = file.read(dl) if el: try: e=loads(file.read(el)) except: e={} else: e={} result = RecordIterator(tid, status, user, description, e, pos, tend, file, tpos) pos=tend # Read the (intentionally redundant) transaction length file.seek(pos) h = file.read(8) if h != stl: error("redundant transaction length check failed at %s", pos) pos += 8 return pos, result
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
file.seek(pos) data = file.read(8096)
f.seek(pos) data = f.read(8096)
def scan(file, pos): """Return a potential transaction location following pos in file. This routine scans forward from pos looking for the last data record in a transaction. A period '.' always occurs at the end of a pickle, and an 8-byte transaction length follows the last pickle. If a period is followed by a plausible 8-byte transaction length, assume that we have found the end of a transaction. The caller should try to verify that the returned location is actually a transaction header. """ while 1: file.seek(pos) data = file.read(8096) if not data: return 0 s = 0 while 1: l = data.find('.', s) if l < 0: pos += len(data) break # If we are less than 8 bytes from the end of the # string, we need to read more data. if l > len(data) - 8: pos += l break s = l + 1 tl = u64(data[s:s+8]) if tl < pos: return pos + s + 8
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
l = data.find('.', s)
l = data.find(".", s)
def scan(file, pos): """Return a potential transaction location following pos in file. This routine scans forward from pos looking for the last data record in a transaction. A period '.' always occurs at the end of a pickle, and an 8-byte transaction length follows the last pickle. If a period is followed by a plausible 8-byte transaction length, assume that we have found the end of a transaction. The caller should try to verify that the returned location is actually a transaction header. """ while 1: file.seek(pos) data = file.read(8096) if not data: return 0 s = 0 while 1: l = data.find('.', s) if l < 0: pos += len(data) break # If we are less than 8 bytes from the end of the # string, we need to read more data. if l > len(data) - 8: pos += l break s = l + 1 tl = u64(data[s:s+8]) if tl < pos: return pos + s + 8
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
if l > len(data) - 8:
s = l + 1 if s > len(data) - 8:
def scan(file, pos): """Return a potential transaction location following pos in file. This routine scans forward from pos looking for the last data record in a transaction. A period '.' always occurs at the end of a pickle, and an 8-byte transaction length follows the last pickle. If a period is followed by a plausible 8-byte transaction length, assume that we have found the end of a transaction. The caller should try to verify that the returned location is actually a transaction header. """ while 1: file.seek(pos) data = file.read(8096) if not data: return 0 s = 0 while 1: l = data.find('.', s) if l < 0: pos += len(data) break # If we are less than 8 bytes from the end of the # string, we need to read more data. if l > len(data) - 8: pos += l break s = l + 1 tl = u64(data[s:s+8]) if tl < pos: return pos + s + 8
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
s = l + 1
def scan(file, pos): """Return a potential transaction location following pos in file. This routine scans forward from pos looking for the last data record in a transaction. A period '.' always occurs at the end of a pickle, and an 8-byte transaction length follows the last pickle. If a period is followed by a plausible 8-byte transaction length, assume that we have found the end of a transaction. The caller should try to verify that the returned location is actually a transaction header. """ while 1: file.seek(pos) data = file.read(8096) if not data: return 0 s = 0 while 1: l = data.find('.', s) if l < 0: pos += len(data) break # If we are less than 8 bytes from the end of the # string, we need to read more data. if l > len(data) - 8: pos += l break s = l + 1 tl = u64(data[s:s+8]) if tl < pos: return pos + s + 8
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
print '.',
print ".",
def iprogress(i): if i % 2: print '.', else: print (i/2) % 10, sys.stdout.flush()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
opts, (inp, outp) = getopt.getopt(sys.argv[1:], 'fv:pP:')
opts, (inp, outp) = getopt.getopt(sys.argv[1:], "fv:pP:")
def main(): try: opts, (inp, outp) = getopt.getopt(sys.argv[1:], 'fv:pP:') except getopt.error: die() print __doc__ % argv[0] force = partial = verbose = 0 pack = None for opt, v in opts: if opt == '-v': verbose = int(v) elif opt == '-p': partial = 1 elif opt == '-f': force = 1 elif opt == '-P': pack = time.time() - float(v) recover(inp, outp, verbose, partial, force, pack)
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
if opt == '-v':
if opt == "-v":
def main(): try: opts, (inp, outp) = getopt.getopt(sys.argv[1:], 'fv:pP:') except getopt.error: die() print __doc__ % argv[0] force = partial = verbose = 0 pack = None for opt, v in opts: if opt == '-v': verbose = int(v) elif opt == '-p': partial = 1 elif opt == '-f': force = 1 elif opt == '-P': pack = time.time() - float(v) recover(inp, outp, verbose, partial, force, pack)
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
elif opt == '-p':
elif opt == "-p":
def main(): try: opts, (inp, outp) = getopt.getopt(sys.argv[1:], 'fv:pP:') except getopt.error: die() print __doc__ % argv[0] force = partial = verbose = 0 pack = None for opt, v in opts: if opt == '-v': verbose = int(v) elif opt == '-p': partial = 1 elif opt == '-f': force = 1 elif opt == '-P': pack = time.time() - float(v) recover(inp, outp, verbose, partial, force, pack)
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
elif opt == '-f':
elif opt == "-f":
def main(): try: opts, (inp, outp) = getopt.getopt(sys.argv[1:], 'fv:pP:') except getopt.error: die() print __doc__ % argv[0] force = partial = verbose = 0 pack = None for opt, v in opts: if opt == '-v': verbose = int(v) elif opt == '-p': partial = 1 elif opt == '-f': force = 1 elif opt == '-P': pack = time.time() - float(v) recover(inp, outp, verbose, partial, force, pack)
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
elif opt == '-P':
elif opt == "-P":
def main(): try: opts, (inp, outp) = getopt.getopt(sys.argv[1:], 'fv:pP:') except getopt.error: die() print __doc__ % argv[0] force = partial = verbose = 0 pack = None for opt, v in opts: if opt == '-v': verbose = int(v) elif opt == '-p': partial = 1 elif opt == '-f': force = 1 elif opt == '-P': pack = time.time() - float(v) recover(inp, outp, verbose, partial, force, pack)
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
print 'Recovering', inp, 'into', outp
print "Recovering", inp, "into", outp
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print 'Recovering', inp, 'into', outp if os.path.exists(outp) and not force: die("%s exists" % outp) file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") file.seek(0,2) file_size = file.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 preindex = {} undone = 0 pos = 4 while pos: try: npos, transaction = read_transaction_header(file, pos, file_size) except EOFError: break except: print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) continue if transaction is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = transaction.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ('Time stamps out of order %s, %s' % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ('Time stamps back in order %s' % (t)) ok = 1 if verbose: print 'begin', if verbose > 1: print sys.stdout.flush() ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in transaction: oid = r.oid if verbose > 1: print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s nrec += 1 except: if partial and nrec: ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'partial' else: ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) else: ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'finish' sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version:
f = open(inp, "rb") if f.read(4) != ZODB.FileStorage.packed_version:
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print 'Recovering', inp, 'into', outp if os.path.exists(outp) and not force: die("%s exists" % outp) file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") file.seek(0,2) file_size = file.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 preindex = {} undone = 0 pos = 4 while pos: try: npos, transaction = read_transaction_header(file, pos, file_size) except EOFError: break except: print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) continue if transaction is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = transaction.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ('Time stamps out of order %s, %s' % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ('Time stamps back in order %s' % (t)) ok = 1 if verbose: print 'begin', if verbose > 1: print sys.stdout.flush() ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in transaction: oid = r.oid if verbose > 1: print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s nrec += 1 except: if partial and nrec: ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'partial' else: ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) else: ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'finish' sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
file.seek(0,2) file_size = file.tell()
f.seek(0,2) file_size = f.tell()
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print 'Recovering', inp, 'into', outp if os.path.exists(outp) and not force: die("%s exists" % outp) file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") file.seek(0,2) file_size = file.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 preindex = {} undone = 0 pos = 4 while pos: try: npos, transaction = read_transaction_header(file, pos, file_size) except EOFError: break except: print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) continue if transaction is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = transaction.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ('Time stamps out of order %s, %s' % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ('Time stamps back in order %s' % (t)) ok = 1 if verbose: print 'begin', if verbose > 1: print sys.stdout.flush() ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in transaction: oid = r.oid if verbose > 1: print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s nrec += 1 except: if partial and nrec: ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'partial' else: ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) else: ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'finish' sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
preindex = {}
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print 'Recovering', inp, 'into', outp if os.path.exists(outp) and not force: die("%s exists" % outp) file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") file.seek(0,2) file_size = file.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 preindex = {} undone = 0 pos = 4 while pos: try: npos, transaction = read_transaction_header(file, pos, file_size) except EOFError: break except: print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) continue if transaction is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = transaction.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ('Time stamps out of order %s, %s' % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ('Time stamps back in order %s' % (t)) ok = 1 if verbose: print 'begin', if verbose > 1: print sys.stdout.flush() ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in transaction: oid = r.oid if verbose > 1: print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s nrec += 1 except: if partial and nrec: ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'partial' else: ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) else: ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'finish' sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
npos, transaction = read_transaction_header(file, pos, file_size)
npos, txn, tid = read_txn_header(f, pos, file_size, outp, ltid)
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print 'Recovering', inp, 'into', outp if os.path.exists(outp) and not force: die("%s exists" % outp) file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") file.seek(0,2) file_size = file.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 preindex = {} undone = 0 pos = 4 while pos: try: npos, transaction = read_transaction_header(file, pos, file_size) except EOFError: break except: print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) continue if transaction is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = transaction.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ('Time stamps out of order %s, %s' % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ('Time stamps back in order %s' % (t)) ok = 1 if verbose: print 'begin', if verbose > 1: print sys.stdout.flush() ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in transaction: oid = r.oid if verbose > 1: print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s nrec += 1 except: if partial and nrec: ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'partial' else: ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) else: ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'finish' sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
except: print "\n%s: %s\n" % sys.exc_info()[:2]
except (KeyboardInterrupt, SystemExit): raise except Exception, err: print "error reading txn header:", err
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print 'Recovering', inp, 'into', outp if os.path.exists(outp) and not force: die("%s exists" % outp) file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") file.seek(0,2) file_size = file.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 preindex = {} undone = 0 pos = 4 while pos: try: npos, transaction = read_transaction_header(file, pos, file_size) except EOFError: break except: print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) continue if transaction is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = transaction.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ('Time stamps out of order %s, %s' % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ('Time stamps back in order %s' % (t)) ok = 1 if verbose: print 'begin', if verbose > 1: print sys.stdout.flush() ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in transaction: oid = r.oid if verbose > 1: print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s nrec += 1 except: if partial and nrec: ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'partial' else: ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) else: ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'finish' sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
pos = scan(file, pos)
pos = scan(f, pos) if verbose > 1: print "looking for valid txn header at", pos
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print 'Recovering', inp, 'into', outp if os.path.exists(outp) and not force: die("%s exists" % outp) file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") file.seek(0,2) file_size = file.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 preindex = {} undone = 0 pos = 4 while pos: try: npos, transaction = read_transaction_header(file, pos, file_size) except EOFError: break except: print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) continue if transaction is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = transaction.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ('Time stamps out of order %s, %s' % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ('Time stamps back in order %s' % (t)) ok = 1 if verbose: print 'begin', if verbose > 1: print sys.stdout.flush() ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in transaction: oid = r.oid if verbose > 1: print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s nrec += 1 except: if partial and nrec: ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'partial' else: ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) else: ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'finish' sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
if transaction is None:
ltid = tid if txn is None:
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print 'Recovering', inp, 'into', outp if os.path.exists(outp) and not force: die("%s exists" % outp) file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") file.seek(0,2) file_size = file.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 preindex = {} undone = 0 pos = 4 while pos: try: npos, transaction = read_transaction_header(file, pos, file_size) except EOFError: break except: print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) continue if transaction is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = transaction.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ('Time stamps out of order %s, %s' % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ('Time stamps back in order %s' % (t)) ok = 1 if verbose: print 'begin', if verbose > 1: print sys.stdout.flush() ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in transaction: oid = r.oid if verbose > 1: print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s nrec += 1 except: if partial and nrec: ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'partial' else: ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) else: ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'finish' sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
tid = transaction.tid
tid = txn.tid
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print 'Recovering', inp, 'into', outp if os.path.exists(outp) and not force: die("%s exists" % outp) file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") file.seek(0,2) file_size = file.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 preindex = {} undone = 0 pos = 4 while pos: try: npos, transaction = read_transaction_header(file, pos, file_size) except EOFError: break except: print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) continue if transaction is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = transaction.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ('Time stamps out of order %s, %s' % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ('Time stamps back in order %s' % (t)) ok = 1 if verbose: print 'begin', if verbose > 1: print sys.stdout.flush() ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in transaction: oid = r.oid if verbose > 1: print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s nrec += 1 except: if partial and nrec: ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'partial' else: ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) else: ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'finish' sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
print ('Time stamps out of order %s, %s' % (_ts, t))
print ("Time stamps out of order %s, %s" % (_ts, t))
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print 'Recovering', inp, 'into', outp if os.path.exists(outp) and not force: die("%s exists" % outp) file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") file.seek(0,2) file_size = file.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 preindex = {} undone = 0 pos = 4 while pos: try: npos, transaction = read_transaction_header(file, pos, file_size) except EOFError: break except: print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) continue if transaction is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = transaction.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ('Time stamps out of order %s, %s' % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ('Time stamps back in order %s' % (t)) ok = 1 if verbose: print 'begin', if verbose > 1: print sys.stdout.flush() ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in transaction: oid = r.oid if verbose > 1: print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s nrec += 1 except: if partial and nrec: ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'partial' else: ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) else: ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'finish' sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
print ('Time stamps back in order %s' % (t))
print ("Time stamps back in order %s" % (t))
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print 'Recovering', inp, 'into', outp if os.path.exists(outp) and not force: die("%s exists" % outp) file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") file.seek(0,2) file_size = file.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 preindex = {} undone = 0 pos = 4 while pos: try: npos, transaction = read_transaction_header(file, pos, file_size) except EOFError: break except: print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) continue if transaction is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = transaction.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ('Time stamps out of order %s, %s' % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ('Time stamps back in order %s' % (t)) ok = 1 if verbose: print 'begin', if verbose > 1: print sys.stdout.flush() ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in transaction: oid = r.oid if verbose > 1: print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s nrec += 1 except: if partial and nrec: ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'partial' else: ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) else: ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'finish' sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
print 'begin',
print "begin", pos, _ts,
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print 'Recovering', inp, 'into', outp if os.path.exists(outp) and not force: die("%s exists" % outp) file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") file.seek(0,2) file_size = file.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 preindex = {} undone = 0 pos = 4 while pos: try: npos, transaction = read_transaction_header(file, pos, file_size) except EOFError: break except: print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) continue if transaction is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = transaction.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ('Time stamps out of order %s, %s' % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ('Time stamps back in order %s' % (t)) ok = 1 if verbose: print 'begin', if verbose > 1: print sys.stdout.flush() ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in transaction: oid = r.oid if verbose > 1: print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s nrec += 1 except: if partial and nrec: ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'partial' else: ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) else: ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'finish' sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush()
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print 'Recovering', inp, 'into', outp if os.path.exists(outp) and not force: die("%s exists" % outp) file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") file.seek(0,2) file_size = file.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 preindex = {} undone = 0 pos = 4 while pos: try: npos, transaction = read_transaction_header(file, pos, file_size) except EOFError: break except: print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) continue if transaction is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = transaction.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ('Time stamps out of order %s, %s' % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ('Time stamps back in order %s' % (t)) ok = 1 if verbose: print 'begin', if verbose > 1: print sys.stdout.flush() ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in transaction: oid = r.oid if verbose > 1: print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s nrec += 1 except: if partial and nrec: ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'partial' else: ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) else: ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'finish' sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
for r in transaction: oid = r.oid
for r in txn:
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print 'Recovering', inp, 'into', outp if os.path.exists(outp) and not force: die("%s exists" % outp) file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") file.seek(0,2) file_size = file.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 preindex = {} undone = 0 pos = 4 while pos: try: npos, transaction = read_transaction_header(file, pos, file_size) except EOFError: break except: print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) continue if transaction is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = transaction.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ('Time stamps out of order %s, %s' % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ('Time stamps back in order %s' % (t)) ok = 1 if verbose: print 'begin', if verbose > 1: print sys.stdout.flush() ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in transaction: oid = r.oid if verbose > 1: print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s nrec += 1 except: if partial and nrec: ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'partial' else: ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) else: ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'finish' sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s
if r.data is None: l = "bp" else: l = len(r.data) print "%7d %s %s" % (u64(r.oid), l, r.version) s = ofs.restore(r.oid, r.serial, r.data, r.version, r.data_txn, txn)
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print 'Recovering', inp, 'into', outp if os.path.exists(outp) and not force: die("%s exists" % outp) file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") file.seek(0,2) file_size = file.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 preindex = {} undone = 0 pos = 4 while pos: try: npos, transaction = read_transaction_header(file, pos, file_size) except EOFError: break except: print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) continue if transaction is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = transaction.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ('Time stamps out of order %s, %s' % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ('Time stamps back in order %s' % (t)) ok = 1 if verbose: print 'begin', if verbose > 1: print sys.stdout.flush() ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in transaction: oid = r.oid if verbose > 1: print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s nrec += 1 except: if partial and nrec: ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'partial' else: ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) else: ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'finish' sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
except:
except (KeyboardInterrupt, SystemExit): raise except Exception, err:
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print 'Recovering', inp, 'into', outp if os.path.exists(outp) and not force: die("%s exists" % outp) file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") file.seek(0,2) file_size = file.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 preindex = {} undone = 0 pos = 4 while pos: try: npos, transaction = read_transaction_header(file, pos, file_size) except EOFError: break except: print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) continue if transaction is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = transaction.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ('Time stamps out of order %s, %s' % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ('Time stamps back in order %s' % (t)) ok = 1 if verbose: print 'begin', if verbose > 1: print sys.stdout.flush() ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in transaction: oid = r.oid if verbose > 1: print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s nrec += 1 except: if partial and nrec: ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'partial' else: ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) else: ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'finish' sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction)
ofs._status = "p" ofs.tpc_vote(txn) ofs.tpc_finish(txn)
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print 'Recovering', inp, 'into', outp if os.path.exists(outp) and not force: die("%s exists" % outp) file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") file.seek(0,2) file_size = file.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 preindex = {} undone = 0 pos = 4 while pos: try: npos, transaction = read_transaction_header(file, pos, file_size) except EOFError: break except: print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) continue if transaction is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = transaction.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ('Time stamps out of order %s, %s' % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ('Time stamps back in order %s' % (t)) ok = 1 if verbose: print 'begin', if verbose > 1: print sys.stdout.flush() ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in transaction: oid = r.oid if verbose > 1: print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s nrec += 1 except: if partial and nrec: ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'partial' else: ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) else: ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'finish' sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
print 'partial'
print "partial"
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print 'Recovering', inp, 'into', outp if os.path.exists(outp) and not force: die("%s exists" % outp) file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") file.seek(0,2) file_size = file.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 preindex = {} undone = 0 pos = 4 while pos: try: npos, transaction = read_transaction_header(file, pos, file_size) except EOFError: break except: print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) continue if transaction is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = transaction.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ('Time stamps out of order %s, %s' % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ('Time stamps back in order %s' % (t)) ok = 1 if verbose: print 'begin', if verbose > 1: print sys.stdout.flush() ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in transaction: oid = r.oid if verbose > 1: print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s nrec += 1 except: if partial and nrec: ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'partial' else: ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) else: ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'finish' sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2]
ofs.tpc_abort(txn) print "error copying transaction:", err
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print 'Recovering', inp, 'into', outp if os.path.exists(outp) and not force: die("%s exists" % outp) file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") file.seek(0,2) file_size = file.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 preindex = {} undone = 0 pos = 4 while pos: try: npos, transaction = read_transaction_header(file, pos, file_size) except EOFError: break except: print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) continue if transaction is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = transaction.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ('Time stamps out of order %s, %s' % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ('Time stamps back in order %s' % (t)) ok = 1 if verbose: print 'begin', if verbose > 1: print sys.stdout.flush() ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in transaction: oid = r.oid if verbose > 1: print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s nrec += 1 except: if partial and nrec: ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'partial' else: ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) else: ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'finish' sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
pos = scan(file, pos)
pos = scan(f, pos) if verbose > 1: print "looking for valid txn header at", pos
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print 'Recovering', inp, 'into', outp if os.path.exists(outp) and not force: die("%s exists" % outp) file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") file.seek(0,2) file_size = file.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 preindex = {} undone = 0 pos = 4 while pos: try: npos, transaction = read_transaction_header(file, pos, file_size) except EOFError: break except: print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) continue if transaction is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = transaction.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ('Time stamps out of order %s, %s' % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ('Time stamps back in order %s' % (t)) ok = 1 if verbose: print 'begin', if verbose > 1: print sys.stdout.flush() ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in transaction: oid = r.oid if verbose > 1: print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s nrec += 1 except: if partial and nrec: ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'partial' else: ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) else: ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'finish' sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
ofs.tpc_vote(transaction) ofs.tpc_finish(transaction)
ofs.tpc_vote(txn) ofs.tpc_finish(txn)
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print 'Recovering', inp, 'into', outp if os.path.exists(outp) and not force: die("%s exists" % outp) file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") file.seek(0,2) file_size = file.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 preindex = {} undone = 0 pos = 4 while pos: try: npos, transaction = read_transaction_header(file, pos, file_size) except EOFError: break except: print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) continue if transaction is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = transaction.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ('Time stamps out of order %s, %s' % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ('Time stamps back in order %s' % (t)) ok = 1 if verbose: print 'begin', if verbose > 1: print sys.stdout.flush() ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in transaction: oid = r.oid if verbose > 1: print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s nrec += 1 except: if partial and nrec: ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'partial' else: ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) else: ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'finish' sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
print 'finish'
print "finish"
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print 'Recovering', inp, 'into', outp if os.path.exists(outp) and not force: die("%s exists" % outp) file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") file.seek(0,2) file_size = file.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 preindex = {} undone = 0 pos = 4 while pos: try: npos, transaction = read_transaction_header(file, pos, file_size) except EOFError: break except: print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) continue if transaction is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = transaction.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ('Time stamps out of order %s, %s' % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ('Time stamps back in order %s' % (t)) ok = 1 if verbose: print 'begin', if verbose > 1: print sys.stdout.flush() ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in transaction: oid = r.oid if verbose > 1: print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s nrec += 1 except: if partial and nrec: ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'partial' else: ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) else: ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'finish' sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
if __name__ == '__main__':
if __name__ == "__main__":
def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print 'Recovering', inp, 'into', outp if os.path.exists(outp) and not force: die("%s exists" % outp) file = open(inp, "rb") if file.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") file.seek(0,2) file_size = file.tell() ofs = ZODB.FileStorage.FileStorage(outp, create=1) _ts = None ok = 1 prog1 = 0 preindex = {} undone = 0 pos = 4 while pos: try: npos, transaction = read_transaction_header(file, pos, file_size) except EOFError: break except: print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) continue if transaction is None: undone = undone + npos - pos pos = npos continue else: pos = npos tid = transaction.tid if _ts is None: _ts = TimeStamp(tid) else: t = TimeStamp(tid) if t <= _ts: if ok: print ('Time stamps out of order %s, %s' % (_ts, t)) ok = 0 _ts = t.laterThan(_ts) tid = `_ts` else: _ts = t if not ok: print ('Time stamps back in order %s' % (t)) ok = 1 if verbose: print 'begin', if verbose > 1: print sys.stdout.flush() ofs.tpc_begin(transaction, tid, transaction.status) if verbose: print 'begin', pos, _ts, if verbose > 1: print sys.stdout.flush() nrec = 0 try: for r in transaction: oid = r.oid if verbose > 1: print u64(oid), r.version, len(r.data) pre = preindex.get(oid) s = ofs.store(oid, pre, r.data, r.version, transaction) preindex[oid] = s nrec += 1 except: if partial and nrec: ofs._status = 'p' ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'partial' else: ofs.tpc_abort(transaction) print "\n%s: %s\n" % sys.exc_info()[:2] if not verbose: progress(prog1) pos = scan(file, pos) else: ofs.tpc_vote(transaction) ofs.tpc_finish(transaction) if verbose: print 'finish' sys.stdout.flush() if not verbose: prog = pos * 20l / file_size while prog > prog1: prog1 = prog1 + 1 iprogress(prog1) bad = file_size - undone - ofs._pos print "\n%s bytes removed during recovery" % bad if undone: print "%s bytes of undone transaction data were skipped" % undone if pack is not None: print "Packing ..." from ZODB.referencesf import referencesf ofs.pack(pack, referencesf) ofs.close()
9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/9bf5e2e14a6436c3a8e756728b18bc7a4b7dd814/fsrecover.py
"""Return the parent of p, n levels up."""
"""Return the ancestor of p from n levels up."""
def parentdir(p, n=1): """Return the parent of p, n levels up.""" d = p while n: d = os.path.split(d)[0] if not d or d == '.': d = os.getcwd() n -= 1 return d
136511231afa030a5231a38a766eae7a651aaa7c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/136511231afa030a5231a38a766eae7a651aaa7c/util.py
d = os.path.split(d)[0]
d = os.path.dirname(d)
def parentdir(p, n=1): """Return the parent of p, n levels up.""" d = p while n: d = os.path.split(d)[0] if not d or d == '.': d = os.getcwd() n -= 1 return d
136511231afa030a5231a38a766eae7a651aaa7c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/136511231afa030a5231a38a766eae7a651aaa7c/util.py
address = ('127.9.9.9', 19999)
portoffset = 0
def handle_read(self): self.recv(8192) self.lock.acquire() try: for thunk in self.thunks: try: thunk() except: nil, t, v, tbinfo = asyncore.compact_traceback() print ('exception in trigger thunk:' ' (%s:%s %s)' % (t, v, tbinfo)) self.thunks = [] finally: self.lock.release()
4ff0c9ad8086c2bdec7550cb4c139175ca92a708 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/10048/4ff0c9ad8086c2bdec7550cb4c139175ca92a708/trigger.py