How to use the pika.amqp_object.Method function in pika

To help you get started, we’ve selected a few pika examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pika / pika / tests / unit / amqp_object_tests.py View on Github external
def test_get_body(self):
        properties = amqp_object.Properties()
        body = 'This is a test'
        obj = amqp_object.Method()
        obj._set_content(properties, body)
        self.assertEqual(obj.get_body(), body)
github pika / pika / pika / spec.py View on Github external
def __init__(self):
            pass

        @property
        def synchronous(self):
            return False

        def decode(self, encoded, offset=0):
            return self

        def encode(self):
            pieces = list()
            return pieces

    class Commit(amqp_object.Method):

        INDEX = 0x005A0014  # 90, 20; 5898260
        NAME = 'Tx.Commit'

        def __init__(self):
            pass

        @property
        def synchronous(self):
            return True

        def decode(self, encoded, offset=0):
            return self

        def encode(self):
            pieces = list()
github pika / pika / pika / spec.py View on Github external
pieces.append(struct.pack('B', self.version_major))
            pieces.append(struct.pack('B', self.version_minor))
            data.encode_table(pieces, self.server_properties)
            assert isinstance(self.mechanisms, str_or_bytes),\
                   'A non-string value was supplied for self.mechanisms'
            value = self.mechanisms.encode('utf-8') if isinstance(self.mechanisms, unicode_type) else self.mechanisms
            pieces.append(struct.pack('>I', len(value)))
            pieces.append(value)
            assert isinstance(self.locales, str_or_bytes),\
                   'A non-string value was supplied for self.locales'
            value = self.locales.encode('utf-8') if isinstance(self.locales, unicode_type) else self.locales
            pieces.append(struct.pack('>I', len(value)))
            pieces.append(value)
            return pieces

    class StartOk(amqp_object.Method):

        INDEX = 0x000A000B  # 10, 11; 655371
        NAME = 'Connection.StartOk'

        def __init__(self, client_properties=None, mechanism='PLAIN', response=None, locale='en_US'):
            self.client_properties = client_properties
            self.mechanism = mechanism
            self.response = response
            self.locale = locale

        @property
        def synchronous(self):
            return False

        def decode(self, encoded, offset=0):
            (self.client_properties, offset) = data.decode_table(encoded, offset)
github pika / pika / pika / spec.py View on Github external
offset += 2
            self.method_id = struct.unpack_from('>H', encoded, offset)[0]
            offset += 2
            return self

        def encode(self):
            pieces = list()
            pieces.append(struct.pack('>H', self.reply_code))
            assert isinstance(self.reply_text, str_or_bytes),\
                   'A non-string value was supplied for self.reply_text'
            data.encode_short_string(pieces, self.reply_text)
            pieces.append(struct.pack('>H', self.class_id))
            pieces.append(struct.pack('>H', self.method_id))
            return pieces

    class CloseOk(amqp_object.Method):

        INDEX = 0x00140029  # 20, 41; 1310761
        NAME = 'Channel.CloseOk'

        def __init__(self):
            pass

        @property
        def synchronous(self):
            return False

        def decode(self, encoded, offset=0):
            return self

        def encode(self):
            pieces = list()
github pika / pika / pika / spec.py View on Github external
'A non-string value was supplied for self.consumer_tag'
            data.encode_short_string(pieces, self.consumer_tag)
            pieces.append(struct.pack('>Q', self.delivery_tag))
            bit_buffer = 0
            if self.redelivered:
                bit_buffer |= 1 << 0
            pieces.append(struct.pack('B', bit_buffer))
            assert isinstance(self.exchange, str_or_bytes),\
                   'A non-string value was supplied for self.exchange'
            data.encode_short_string(pieces, self.exchange)
            assert isinstance(self.routing_key, str_or_bytes),\
                   'A non-string value was supplied for self.routing_key'
            data.encode_short_string(pieces, self.routing_key)
            return pieces

    class Get(amqp_object.Method):

        INDEX = 0x003C0046  # 60, 70; 3932230
        NAME = 'Basic.Get'

        def __init__(self, ticket=0, queue='', no_ack=False):
            self.ticket = ticket
            self.queue = queue
            self.no_ack = no_ack

        @property
        def synchronous(self):
            return True

        def decode(self, encoded, offset=0):
            self.ticket = struct.unpack_from('>H', encoded, offset)[0]
            offset += 2
github pika / pika / pika / spec.py View on Github external
self.response = str(self.response)
            except UnicodeEncodeError:
                pass
            offset += length
            return self

        def encode(self):
            pieces = list()
            assert isinstance(self.response, str_or_bytes),\
                   'A non-string value was supplied for self.response'
            value = self.response.encode('utf-8') if isinstance(self.response, unicode_type) else self.response
            pieces.append(struct.pack('>I', len(value)))
            pieces.append(value)
            return pieces

    class Tune(amqp_object.Method):

        INDEX = 0x000A001E  # 10, 30; 655390
        NAME = 'Connection.Tune'

        def __init__(self, channel_max=0, frame_max=0, heartbeat=0):
            self.channel_max = channel_max
            self.frame_max = frame_max
            self.heartbeat = heartbeat

        @property
        def synchronous(self):
            return True

        def decode(self, encoded, offset=0):
            self.channel_max = struct.unpack_from('>H', encoded, offset)[0]
            offset += 2
github pika / pika / pika / spec.py View on Github external
self.channel_id = str(self.channel_id)
            except UnicodeEncodeError:
                pass
            offset += length
            return self

        def encode(self):
            pieces = list()
            assert isinstance(self.channel_id, str_or_bytes),\
                   'A non-string value was supplied for self.channel_id'
            value = self.channel_id.encode('utf-8') if isinstance(self.channel_id, unicode_type) else self.channel_id
            pieces.append(struct.pack('>I', len(value)))
            pieces.append(value)
            return pieces

    class Flow(amqp_object.Method):

        INDEX = 0x00140014  # 20, 20; 1310740
        NAME = 'Channel.Flow'

        def __init__(self, active=None):
            self.active = active

        @property
        def synchronous(self):
            return True

        def decode(self, encoded, offset=0):
            bit_buffer = struct.unpack_from('B', encoded, offset)[0]
            offset += 1
            self.active = (bit_buffer & (1 << 0)) != 0
            return self
github pika / pika / pika / spec.py View on Github external
bit_buffer = 0
            if self.passive:
                bit_buffer |= 1 << 0
            if self.durable:
                bit_buffer |= 1 << 1
            if self.auto_delete:
                bit_buffer |= 1 << 2
            if self.internal:
                bit_buffer |= 1 << 3
            if self.nowait:
                bit_buffer |= 1 << 4
            pieces.append(struct.pack('B', bit_buffer))
            data.encode_table(pieces, self.arguments)
            return pieces

    class DeclareOk(amqp_object.Method):

        INDEX = 0x0028000B  # 40, 11; 2621451
        NAME = 'Exchange.DeclareOk'

        def __init__(self):
            pass

        @property
        def synchronous(self):
            return False

        def decode(self, encoded, offset=0):
            return self

        def encode(self):
            pieces = list()
github pika / pika / pika / spec.py View on Github external
def __init__(self):
            pass

        @property
        def synchronous(self):
            return True

        def decode(self, encoded, offset=0):
            return self

        def encode(self):
            pieces = list()
            return pieces

    class CommitOk(amqp_object.Method):

        INDEX = 0x005A0015  # 90, 21; 5898261
        NAME = 'Tx.CommitOk'

        def __init__(self):
            pass

        @property
        def synchronous(self):
            return False

        def decode(self, encoded, offset=0):
            return self

        def encode(self):
            pieces = list()
github pika / pika / pika / spec.py View on Github external
def __init__(self):
            pass

        @property
        def synchronous(self):
            return False

        def decode(self, encoded, offset=0):
            return self

        def encode(self):
            pieces = list()
            return pieces

    class Purge(amqp_object.Method):

        INDEX = 0x0032001E  # 50, 30; 3276830
        NAME = 'Queue.Purge'

        def __init__(self, ticket=0, queue='', nowait=False):
            self.ticket = ticket
            self.queue = queue
            self.nowait = nowait

        @property
        def synchronous(self):
            return True

        def decode(self, encoded, offset=0):
            self.ticket = struct.unpack_from('>H', encoded, offset)[0]
            offset += 2