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)
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
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
def pack(self): self.s.sendall('P') status = recv(self.s, 1) if status != STATUS_OKAY: raise ProtocolError, 'server returned invalid status %r' % status
def new_oid(self): self.s.sendall('N') oid = recv(self.s, 8) return oid