2 # Simple read() method around a bytearray
14 def reset_count(self):
24 # b should be castable to byte array
25 self.buf += bytearray(b)
29 print "reader err: buf less than n"
34 self.buf = self.buf[n:]
37 # Buffer bytes off a tcp connection and read them off in chunks
42 def __init__(self, conn):
44 self.buf = bytearray()
48 while n > len(self.buf):
49 moreBuf = self.conn.recv(1024)
51 raise IOError("dead connection")
52 self.buf = self.buf + bytearray(moreBuf)
55 self.buf = self.buf[n:]