Example #1
0
 def decX(self, l):
     if len(self.bytes) < l :
         raise py9p.Error("buffer exhausted")
     x = "".join(self.bytes[:l])
     #del self.bytes[:l]
     self.bytes[:l] = [] # significant speedup
     return x
Example #2
0
 def recv(self, fd):
     "Read and decode a message"
     self.setBuf(fd.read(4))
     size = self.dec4()
     if size > self.MAXSIZE or size < 4:
         raise py9p.Error("Bad message size: %d" % size)
     self.setBuf(fd.read(size - 4))
     type,tag = self.dec1(),self.dec2()
     self._checkType(type)
     fcall = py9p.Fcall(type, tag)
     self.dec(fcall)
     self._checkResid()
     if self.chatty:
         print "<-%d-" % fd.fileno(), py9p.cmdName[type], tag, fcall.tostr()
     return fcall
Example #3
0
 def _checkLen(self, x, l):
     if len(x) != l:
         raise py9p.Error("Wrong length %d, expected %d: %r" % (len(x), l, x))
Example #4
0
 def _checkSize(self, v, mask):
     if v != v & mask:
         raise py9p.Error("Invalid value %d" % v)
Example #5
0
 def _checkResid(self):
     if len(self.bytes):
         raise py9p.Error("Extra information in message: %r" % self.bytes)
Example #6
0
 def _checkType(self, t):
     if t not in py9p.cmdName:
         raise py9p.Error("Invalid message type %d" % t)