Ejemplo n.º 1
0
 def sync(self):
     self.s.sendall('S')
     n = u32(recv(self.s, 4))
     if n == 0:
         packed_oids = ''
     else:
         packed_oids = recv(self.s, n*8)
     return split_oids(packed_oids)
Ejemplo n.º 2
0
 def load(self, oid):
     self.s.sendall('L' + oid)
     status = recv(self.s, 1)
     if status == STATUS_OKAY:
         pass
     elif status == STATUS_INVALID:
         raise ReadConflictError([oid])
     elif status == STATUS_KEYERROR:
         raise DurusKeyError(oid)
     else:
         raise ProtocolError, 'server returned invalid status %r' % status
     rlen = u32(recv(self.s, 4))
     record = recv(self.s, rlen)
     return record
Ejemplo n.º 3
0
 def end(self, handle_invalidations=None):
     self.s.sendall('C')
     n = u32(recv(self.s, 4))
     if n != 0:
         packed_oids = recv(self.s, n*8)
         try:
             handle_invalidations(split_oids(packed_oids))
         except ConflictError:
             self.s.sendall(p32(0)) # Tell server we are done.
             raise
     tdata = []
     for oid, record in self.records.iteritems():
         tdata.append(p32(8 + len(record)))
         tdata.append(oid)
         tdata.append(record)
     tdata = ''.join(tdata)
     self.s.sendall(p32(len(tdata)))
     self.s.sendall(tdata)
     self.records.clear()
     status = recv(self.s, 1)
     if status != STATUS_OKAY:
         raise ProtocolError, 'server returned invalid status %r' % status
Ejemplo n.º 4
0
 def pack(self):
     self.s.sendall('P')
     status = recv(self.s, 1)
     if status != STATUS_OKAY:
         raise ProtocolError, 'server returned invalid status %r' % status
Ejemplo n.º 5
0
 def new_oid(self):
     self.s.sendall('N')
     oid = recv(self.s, 8)
     return oid