Beispiel #1
0
 def read_8_0(self):
     c = self.codec
     tid = c.decode_octet()
     try:
         type = self.spec.constants.byid[tid].name
     except KeyError:
         if tid == ord('A') and c.unpack("!3s") == "MQP":
             _, _, major, minor = c.unpack("4B")
             raise VersionError(
                 "client: %s-%s, server: %s-%s" %
                 (self.spec.major, self.spec.minor, major, minor))
         else:
             raise FramingError("unknown frame type: %s" % tid)
     channel = c.decode_short()
     body = c.decode_longstr()
     dec = codec.Codec(StringIO(body), self.spec)
     frame = Frame.DECODERS[type].decode(self.spec, dec, len(body))
     frame.channel = channel
     end = c.decode_octet()
     if end != self.FRAME_END:
         garbage = ""
         while end != self.FRAME_END:
             garbage += chr(end)
             end = c.decode_octet()
         raise "frame error: expected %r, got %r" % (self.FRAME_END,
                                                     garbage)
     return frame
Beispiel #2
0
  def read_8_0(self):
    c = self.codec
    tid = c.decode_octet()
    try:
      type = self.spec.constants.byid[tid].name
    except KeyError:
      if tid == ord('A') and c.unpack("!3s") == "MQP":
        _, _, major, minor = c.unpack("4B")
        raise VersionError("client: %s-%s, server: %s-%s" %
                           (self.spec.major, self.spec.minor, major, minor))
      else:
        raise FramingError("unknown frame type: %s" % tid)
    try:
      channel = c.decode_short()
      body = c.decode_longstr()
      dec = codec.Codec(StringIO(body), self.spec)
      frame = Frame.DECODERS[type].decode(self.spec, dec, len(body))
      frame.channel = channel
      end = c.decode_octet()
      if end != self.FRAME_END:
	      garbage = ""
	      while end != self.FRAME_END:
	        garbage += chr(end)
	        end = c.decode_octet()
	      raise FramingError("frame error: expected %r, got %r" % (self.FRAME_END, garbage))
      return frame
    except EOF:
      # An EOF caught here can indicate an error decoding the frame,
      # rather than that a disconnection occurred,so it's worth logging it.
      log.exception("Error occurred when reading frame with tid %s" % tid)
      raise
Beispiel #3
0
 def start(self):
   # XXX
   cli_major = 0
   cli_minor = 10
   self.connection.write_header(cli_major, cli_minor)
   magic, _, _, major, minor = self.connection.read_header()
   if not (magic == "AMQP" and major == cli_major and minor == cli_minor):
     raise VersionError("client: %s-%s, server: %s-%s" %
                        (cli_major, cli_minor, major, minor))