Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def tid2time(tid):
return str(TimeStamp(tid))
def run(path, tid):
f = open(path, "rb")
f.seek(0, 2)
th = prev_txn(f)
while (str(TimeStamp(th.tid)) != tid):
th = th.prev_txn()
reader = Reader()
iterator = FileIterator(path, pos=th._pos)
header = TxnHeader(f,th._pos)
for i in iterator:
if(str(TimeStamp(i.tid)) == tid):
print "\nTRANSACTION: ", TimeStamp(i.tid), i.user, i.description, pretty_size(header.length),"\n"
header = header.next_txn()
object_types = {}
for o in i:
ot = reader.getIdentity(o.data)
print " - ", ot, pretty_size(len(o.data))
ob = cPickle.loads(o.data)
# Not sure why some objects are stored as tuple (object, ())
if type(ob) == tuple and len(ob) == 2:
ob = ob[0]
if hasattr(ob, "__dict__"):
for i in ob.__dict__.items():
if str(i[0]) == "__doc__":
print "\t('__doc__',", i[1],")"
elif not callable(i[1]):
print "\t",i
else:
def _splat(self):
"""Spit out a string showing state."""
o = []
o.append('Index:')
keys = self._index.keys()
keys.sort()
for oid in keys:
r = self._index[oid]
o.append(' %s: %s, %s' %
(utils.u64(oid),TimeStamp(r[:8]),`r[8:]`))
return '\n'.join(o)
def _tidToTimestamp(self, tid):
if isinstance(tid, str) and len(tid) == 8:
return str(TimeStamp(tid))
return tid_repr(tid)
if verbose > 1:
print "looking for valid txn header at", pos
continue
ltid = tid
if txn is None:
undone = undone + npos - pos
pos = npos
continue
else:
pos = npos
tid = txn.tid
if _ts is None:
_ts = TimeStamp(tid)
else:
t = TimeStamp(tid)
if t <= _ts:
if ok:
print ("Time stamps out of order %s, %s" % (_ts, t))
ok = 0
_ts = t.laterThan(_ts)
tid = `_ts`
else:
_ts = t
if not ok:
print ("Time stamps back in order %s" % (t))
ok = 1
ofs.tpc_begin(txn, tid, txn.status)
def __init__(self, name, base=None):
self.__name__= name
log.debug("create storage %s", self.__name__)
# Allocate locks:
l = threading.RLock()
self._lock_acquire = l.acquire
self._lock_release = l.release
l = threading.Lock()
self._commit_lock_acquire = l.acquire
self._commit_lock_release = l.release
t=time.time()
t=self._ts=apply(TimeStamp,(time.gmtime(t)[:5]+(t%60,)))
self._tid = `t`
if base is None:
self._oid='\0\0\0\0\0\0\0\0'
else:
self._oid=base._oid
def run(path, days, notPacked):
f = open(path, "rb")
f.seek(0, 2)
now = datetime.date.today()
#day->size
stats = {}
th = prev_txn(f)
bool = True
while bool:
ts = TimeStamp(th.tid)
then = datetime.date(int(ts.year()), int(ts.month()), int(ts.day()))
delta = timedelta(days=int(days))
if( not(now - then < delta)):
bool = False
th = th.prev_txn()
reader = Reader()
iterator = FileIterator(path, pos=th._pos)
for i in iterator:
object_types = {}
for o in i:
ot = reader.getIdentity(o.data)
try:
stats[ot] = stats[ot] + 1
except KeyError:
stats[ot] = 1
def _tidToTimestamp(self, tid):
if isinstance(tid, bytes) and len(tid) == 8:
return str(TimeStamp(tid))
return tid_repr(tid)