def fromArgumentsList(self, list):
        unwrapper = AMQPUnwrapper()
        if isinstance(list, TLVList):
            size = len(list.getList())
            if size == 0:
                raise ValueError(
                    "Received malformed SASL-Outcome header: code can't be null"
                )
            if size > 2:
                raise ValueError(
                    'Received malformed SASL-Outcome header. Invalid number of arguments: '
                    + str(size))

            if size > 0:
                element = list.getList()[0]
                if element is None or element.isNull():
                    raise ValueError(
                        "Received malformed SASL-Outcome header: code can't be null"
                    )
                self.outcomeCode = OutcomeCode(
                    unwrapper.unwrapUByte(element)).value

            if size > 1:
                element = list.getList()[1]
                if element is not None:
                    self.additionalData = unwrapper.unwrapBinary(element)
 def fromArgumentsList(self, list):
     unwrapper = AMQPUnwrapper()
     if isinstance(list, TLVList):
         size = len(list.getList())
         if size == 0:
             raise ValueError(
                 "Received malformed Detach header: handle can't be null")
         if size > 3:
             raise ValueError(
                 "Received malformed Detach header. Invalid number of arguments: "
                 + str(size))
         if size > 0:
             element = list.getList()[0]
             if element is None and not element.isNull():
                 raise ValueError(
                     "Received malformed Detach header: handle can't be null"
                 )
             self.handle = unwrapper.unwrapUInt(element)
         if size > 1:
             element = list.getList()[1]
             if element is not None and not element.isNull():
                 self.closed = unwrapper.unwrapBool(element)
         if size > 2:
             element = list.getList()[2]
             if element is not None and not element.isNull() and isinstance(
                     element, TLVAmqp):
                 code = element.getCode()
                 if code not in (AMQPType.LIST_0, AMQPType.LIST_8,
                                 AMQPType.LIST_32):
                     raise ValueError("Expected type 'ERROR' - received: " +
                                      str(element.getCode()))
                 self.error = AMQPError(None, None, None)
                 self.error.fromArgumentsList(element)
Exemplo n.º 3
0
 def fromArgumentsList(self, list):
     unwrapper = AMQPUnwrapper()
     if isinstance(list, TLVList):
         size = len(list.getList())
         if size < 4:
             raise ValueError(
                 'Received malformed Begin header: mandatory fields next-outgoing-id, incoming-window and outgoing-window must not be null'
             )
         if size > 8:
             raise ValueError(
                 'Received malformed Begin header. Invalid number of arguments: '
                 + str(size))
         if size > 0:
             element = list.getList()[0]
             if element is not None and not element.isNull():
                 self.remoteChannel = unwrapper.unwrapUShort(element)
         if size > 1:
             element = list.getList()[1]
             if element is not None and not element.isNull():
                 self.nextOutgoingId = unwrapper.unwrapUInt(element)
             else:
                 raise ValueError(
                     "Received malformed Begin header: next-outgoing-id can't be null"
                 )
         if size > 2:
             element = list.getList()[2]
             if element is not None and not element.isNull():
                 self.incomingWindow = unwrapper.unwrapUInt(element)
             else:
                 raise ValueError(
                     "Received malformed Begin header: incoming-window can't be null"
                 )
         if size > 3:
             element = list.getList()[3]
             if element is not None and not element.isNull():
                 self.outgoingWindow = unwrapper.unwrapUInt(element)
             else:
                 raise ValueError(
                     "Received malformed Begin header: outgoing-window can't be null"
                 )
         if size > 4:
             element = list.getList()[4]
             if element is not None and not element.isNull():
                 self.handleMax = unwrapper.unwrapUInt(element)
         if size > 5:
             element = list.getList()[5]
             if element is not None and not element.isNull():
                 self.offeredCapabilities = unwrapper.unwrapArray(element)
         if size > 6:
             element = list.getList()[6]
             if element is not None and not element.isNull():
                 self.desiredCapabilities = unwrapper.unwrapArray(element)
         if size > 7:
             element = list.getList()[7]
             if element is not None and not element.isNull():
                 self.properties = unwrapper.unwrapMap(element)
 def fromArgumentsList(self, list):
     if isinstance(list, TLVList):
         size = len(list.getList())
         if size > 0:
             element = list.getList()[0]
             if element is None and not element.isNull():
                 raise ValueError(
                     "Received malformed SASL-Init header: mechanism can't be null"
                 )
             unwrapper = AMQPUnwrapper()
             self.mechanisms = unwrapper.unwrapArray(element)
 def fromArgumentsList(self, list):
     unwrapper = AMQPUnwrapper()
     if isinstance(list, TLVList):
         size = len(list.getList())
         if size == 0:
             raise ValueError("Received malformed SASL-Init header: mechanism can't be null")
         if size > 3:
             raise ValueError('Received malformed SASL-Init header. Invalid number of arguments: ' + str(size))
         if size > 0:
             element = list.getList()[0]
             if element is None or element.isNull():
                 raise ValueError("Received malformed SASL-Init header: mechanism can't be null")
             self.mechanism = unwrapper.unwrapSymbol(element)
         if size > 1:
             element = list.getList()[1]
             if element is not None and not element.isNull():
                 self.initialRespone = unwrapper.unwrapBinary(element)
         if size > 2:
             element = list.getList()[2]
             if element is not None and not element.isNull():
                 self.hostName = unwrapper.unwrapString(element)
 def fromArgumentsList(self, list):
     unwrapper = AMQPUnwrapper()
     if isinstance(list, TLVList):
         if len(list.getList()) > 0 :
             element = list.getList()[0]
             if element is not None and not unwrapper.check_is_null(element):
                 self.condition = ErrorCode(unwrapper.unwrapSymbol(element).getValue())
         if len(list.getList()) > 1 :
             element = list.getList()[1]
             if element is not None and not unwrapper.check_is_null(element):
                 self.description = unwrapper.unwrapString(element)
         if len(list.getList()) > 2 :
             element = list.getList()[2]
             if element is not None and not unwrapper.check_is_null(element):
                 self.info = unwrapper.unwrapMap(element)
 def fromArgumentsList(self, list):
     unwrapper = AMQPUnwrapper()
     if isinstance(list, TLVList):
         if len(list.getList()) > 0:
             element = list.getList()[0]
             if element is not None and not element.isNull():
                 self.address = unwrapper.unwrapString(element)
         if len(list.getList()) > 1:
             element = list.getList()[1]
             if element is not None and not element.isNull():
                 self.durable = TerminusDurability(
                     unwrapper.unwrapUInt(element))
         if len(list.getList()) > 2:
             element = list.getList()[2]
             if element is not None and not element.isNull():
                 self.expiryPeriod = TerminusExpiryPolicy(
                     unwrapper.unwrapSymbol(element))
         if len(list.getList()) > 3:
             element = list.getList()[3]
             if element is not None and not element.isNull():
                 self.timeout = unwrapper.unwrapUInt(element)
         if len(list.getList()) > 4:
             element = list.getList()[4]
             if element is not None and not element.isNull():
                 self.dynamic = unwrapper.unwrapBool(element)
         if len(list.getList()) > 5:
             element = list.getList()[5]
             if element is not None and not element.isNull():
                 if self.dynamic is not None:
                     self.dynamicNodeProperties = unwrapper.unwrapMap(
                         element)
                 else:
                     raise ValueError(
                         "Received malformed Target: dynamic-node-properties can't be specified when dynamic flag is false"
                     )
             else:
                 raise ValueError(
                     "Received malformed Target: dynamic-node-properties can't be specified when dynamic flag is not set"
                 )
         if len(list.getList()) > 6:
             element = list.getList()[6]
             if element is not None and not element.isNull():
                 self.capabilities = unwrapper.unwrapArray(element)
    def fromArgumentsList(self, list):
        unwrapper = AMQPUnwrapper()
        if isinstance(list, TLVList):
            size = len(list.getList())
            if size < 2:
                raise ValueError(
                    "Received malformed Disposition header: role and first can't be null"
                )
            if size > 6:
                raise ValueError(
                    "Received malformed Disposition header. Invalid number of arguments: "
                    + str(size))

            if size > 0:
                element = list.getList()[0]
                if element is None and not element.isNull():
                    raise ValueError(
                        "Received malformed Disposition header: role can't be null"
                    )
                self.role = unwrapper.unwrapBool(element)
            if size > 1:
                element = list.getList()[1]
                if element is None and not element.isNull():
                    raise ValueError(
                        "Received malformed Disposition header: first can't be null"
                    )
                self.first = unwrapper.unwrapUInt(element)
            if size > 2:
                element = list.getList()[2]
                if element is not None and not element.isNull():
                    self.last = unwrapper.unwrapUInt(element)
            if size > 3:
                element = list.getList()[3]
                if element is not None and not element.isNull():
                    self.settled = unwrapper.unwrapBool(element)
            if size > 4:
                element = list.getList()[4]
                if element is not None and not element.isNull() and isinstance(
                        element, TLVAmqp):
                    code = element.getCode()
                    if code not in (AMQPType.LIST_0, AMQPType.LIST_8,
                                    AMQPType.LIST_32):
                        raise ValueError('Expected type STATE - received: ' +
                                         str(element.getCode()))
                    self.state = HeaderFactoryOutcome.getState(element)
                    self.state.fromArgumentsList(element)
            if size > 5:
                element = list.getList()[5]
                if element is not None and not element.isNull():
                    self.batchable = unwrapper.unwrapBool(element)
Exemplo n.º 9
0
    def fromArgumentsList(self, list):
        unwrapper = AMQPUnwrapper()
        if isinstance(list, TLVList):
            size = len(list.getList())
            if size < 3:
                raise ValueError(
                    'Received malformed Attach header: mandatory fields name, handle and role must not be null'
                )
            if size > 14:
                raise ValueError(
                    'Received malformed Attach header. Invalid number of arguments: '
                    + str(size))

            if size > 0:
                element = list.getList()[0]
                if element is not None and not element.isNull():
                    self.name = unwrapper.unwrapString(element)
                else:
                    raise ValueError(
                        "Received malformed Attach header: name can't be null")
            if size > 1:
                element = list.getList()[1]
                if element is not None and not element.isNull():
                    self.handle = unwrapper.unwrapUInt(element)
                else:
                    raise ValueError(
                        "Received malformed Attach header: handle can't be null"
                    )
            if size > 2:
                element = list.getList()[2]
                if element is not None and not element.isNull():
                    self.role = RoleCode(unwrapper.unwrapBool(element))
                else:
                    raise ValueError(
                        "Received malformed Attach header: role can't be null")
            if size > 3:
                element = list.getList()[3]
                if element is not None and not element.isNull():
                    self.sndSettleMode = SendCode(
                        unwrapper.unwrapUByte(element))
            if size > 4:
                element = list.getList()[4]
                if element is not None and not element.isNull():
                    self.rcvSettleMode = ReceiveCode(
                        unwrapper.unwrapUByte(element))
            if size > 5:
                element = list.getList()[5]
                if element is not None and not element.isNull() and isinstance(
                        element, TLVAmqp):
                    code = element.getCode()
                    if code not in (AMQPType.LIST_0, AMQPType.LIST_8,
                                    AMQPType.LIST_32):
                        raise ValueError('Expected type SOURCE - received: ' +
                                         str(element.getCode()))
                    self.source = AMQPSource(None, None, None, None, None,
                                             None, None, None, None, None,
                                             None)
                    self.source.fromArgumentsList(element)
            if size > 6:
                element = list.getList()[6]
                if element is not None and not element.isNull() and isinstance(
                        element, TLVAmqp):
                    code = element.getCode()
                    if code not in (AMQPType.LIST_0, AMQPType.LIST_8,
                                    AMQPType.LIST_32):
                        raise ValueError('Expected type TARGET - received: ' +
                                         str(element.getCode()))
                    self.target = AMQPTarget(None, None, None, None, None,
                                             None, None)
                    self.target.fromArgumentsList(element)
            if size > 7:
                element = list.getList()[7]
                if element is not None and not element.isNull():
                    self.unsettled = unwrapper.unwrapMap(element)
            if size > 8:
                element = list.getList()[8]
                if element is not None and not element.isNull():
                    self.incompleteUnsettled = unwrapper.unwrapBool(element)
            if size > 9:
                element = list.getList()[9]
                if element is not None and not element.isNull():
                    self.initialDeliveryCount = unwrapper.unwrapUInt(element)
                elif self.role == RoleCode.SENDER:
                    raise ValueError(
                        'Received an attach header with a null initial-delivery-count'
                    )
            if size > 10:
                element = list.getList()[10]
                if element is not None and not element.isNull():
                    self.maxMessageSize = unwrapper.unwrapULong(element)
            if size > 11:
                element = list.getList()[11]
                if element is not None and not element.isNull():
                    self.offeredCapabilities = unwrapper.unwrapArray(element)
            if size > 12:
                element = list.getList()[12]
                if element is not None and not element.isNull():
                    self.desiredCapabilities = unwrapper.unwrapArray(element)
            if size > 13:
                element = list.getList()[13]
                if element is not None and not element.isNull():
                    self.properties = unwrapper.unwrapMap(element)
    def fromArgumentsList(self, list):
        unwrapper = AMQPUnwrapper()
        if isinstance(list, TLVList):
            if len(list.getList()) > 0:
                element = list.getList()[0]
                if element is not None and not element.isNull():
                    self.address = unwrapper.unwrapString(element)
            if len(list.getList()) > 1:
                element = list.getList()[1]
                if element is not None and not element.isNull():
                    self.durable = TerminusDurability(
                        unwrapper.unwrapUInt(element))
            if len(list.getList()) > 2:
                element = list.getList()[2]
                if element is not None and not element.isNull():
                    self.expiryPeriod = TerminusExpiryPolicy(
                        unwrapper.unwrapSymbol(element))
            if len(list.getList()) > 3:
                element = list.getList()[3]
                if element is not None and not element.isNull():
                    self.timeout = unwrapper.unwrapUInt(element)
            if len(list.getList()) > 4:
                element = list.getList()[4]
                if element is not None and not element.isNull():
                    self.dynamic = unwrapper.unwrapBool(element)
            if len(list.getList()) > 5:
                element = list.getList()[5]
                if element is not None and not element.isNull():
                    if self.dynamic is not None:
                        if self.dynamic:
                            self.dynamicNodeProperties = unwrapper.unwrapMap(
                                element)
                        else:
                            raise ValueError(
                                "Received malformed Source: dynamic-node-properties can't be specified when dynamic flag is false"
                            )
                    else:
                        raise ValueError(
                            "Received malformed Source: dynamic-node-properties can't be specified when dynamic flag is not set"
                        )

            if len(list.getList()) > 6:
                element = list.getList()[6]
                if element is not None and not element.isNull():
                    self.distributionMode = DistributionMode(
                        unwrapper.unwrapSymbol(element))
            if len(list.getList()) > 7:
                element = list.getList()[7]
                if element is not None and not element.isNull():
                    self.filter = unwrapper.unwrapMap(element)

            if len(list.getList()) > 8:
                element = list.getList()[8]
                if element is not None and not element.isNull() and isinstance(
                        element, TLVAmqp):
                    code = element.getCode()
                    if code not in (AMQPType.LIST_0, AMQPType.LIST_8,
                                    AMQPType.LIST_32):
                        raise ValueError('Expected type OUTCOME - received: ' +
                                         element.getCode())

                self.defaultOutcome = HeaderFactoryOutcome.getOutcome(element)
                self.defaultOutcome.fromArgumentsList(element)

            if len(list.getList()) > 9:
                element = list.getList()[9]
                if element is not None and not element.isNull():
                    self.outcomes = unwrapper.unwrapArray(element)
            if len(list.getList()) > 10:
                element = list.getList()[10]
                if element is not None and not element.isNull():
                    self.capabilities = unwrapper.unwrapArray(element)
Exemplo n.º 11
0
 def fromArgumentsList(self, list):
     unwrapper = AMQPUnwrapper()
     if isinstance(list, TLVList):
         size = len(list.getList())
         if size == 0:
             raise ValueError(
                 "Received malformed Transfer header: handle can't be null")
         if size > 11:
             raise ValueError(
                 'Received malformed Transfer header. Invalid number of arguments: '
                 + str(size))
         if size > 0:
             element = list.getList()[0]
             if element is None and not element.isNull():
                 raise ValueError(
                     "Received malformed Transfer header: handle can't be null"
                 )
             self.handle = unwrapper.unwrapUInt(element)
         if size > 1:
             element = list.getList()[1]
             if element is not None and not element.isNull():
                 self.deliveryId = unwrapper.unwrapUInt(element)
         if size > 2:
             element = list.getList()[2]
             if element is not None and not element.isNull():
                 self.deliveryTag = unwrapper.unwrapBinary(element)
         if size > 3:
             element = list.getList()[3]
             if element is not None and not element.isNull():
                 self.messageFormat = AMQPMessageFormat(
                     unwrapper.unwrapUInt(element))
         if size > 4:
             element = list.getList()[4]
             if element is not None and not element.isNull():
                 self.settled = unwrapper.unwrapBool(element)
         if size > 5:
             element = list.getList()[5]
             if element is not None and not element.isNull():
                 self.more = unwrapper.unwrapBool(element)
         if size > 6:
             element = list.getList()[6]
             if element is not None and not element.isNull():
                 self.rcvSettleMode = ReceiveCode(
                     unwrapper.unwrapUByte(element))
         if size > 7:
             element = list.getList()[7]
             if element is not None and not element.isNull() and isinstance(
                     element, TLVAmqp):
                 code = element.getCode()
                 if code not in (AMQPType.LIST_0, AMQPType.LIST_8,
                                 AMQPType.LIST_32):
                     raise ValueError("Expected type 'STATE' - received: " +
                                      str(element.getCode()))
                 self.state = HeaderFactoryOutcome.getState(element)
                 self.state.fromArgumentsList(element)
         if size > 8:
             element = list.getList()[8]
             if element is not None and not element.isNull():
                 self.resume = unwrapper.unwrapBool(element)
         if size > 9:
             element = list.getList()[9]
             if element is not None and not element.isNull():
                 self.aborted = unwrapper.unwrapBool(element)
         if size > 10:
             element = list.getList()[10]
             if element is not None and not element.isNull():
                 self.batchable = unwrapper.unwrapBool(element)
    def fromArgumentsList(self, list):
        unwrapper = AMQPUnwrapper()
        if isinstance(list, TLVList):
            size = len(list.getList())
            if size < 4:
                raise ValueError(
                    'Received malformed Flow header: mandatory fields incoming-window, next-outgoing-id and outgoing-window must not be null'
                )
            if size > 11:
                raise ValueError(
                    'Received malformed Flow header. Invalid number of arguments: '
                    + str(size))

            if size > 0:
                element = list.getList()[0]
                if element is not None and not element.isNull():
                    self.nextIncomingId = unwrapper.unwrapUInt(element)
            if size > 1:
                element = list.getList()[1]
                if element is not None and not element.isNull():
                    self.incomingWindow = unwrapper.unwrapUInt(element)
                else:
                    raise ValueError(
                        "Received malformed Flow header: incoming-window can't be null"
                    )
            if size > 2:
                element = list.getList()[2]
                if element is not None and not element.isNull():
                    self.nextOutgoingId = unwrapper.unwrapUInt(element)
                else:
                    raise ValueError(
                        "Received malformed Begin header:next-outgoing-id can't be null"
                    )
            if size > 3:
                element = list.getList()[3]
                if element is not None and not element.isNull():
                    self.outgoingWindow = unwrapper.unwrapUInt(element)
                else:
                    raise ValueError(
                        "Received malformed Begin header: outgoing-window can't be null"
                    )
            if size > 4:
                element = list.getList()[4]
                if element is not None and not element.isNull():
                    self.handle = unwrapper.unwrapUInt(element)
            if size > 5:
                element = list.getList()[5]
                if element is not None:
                    if self.handle is not None and not element.isNull():
                        self.deliveryCount = unwrapper.unwrapUInt(element)
                    else:
                        raise ValueError(
                            "Received malformed Flow header: delivery-count can't be present when handle is null"
                        )
            if size > 6:
                element = list.getList()[6]
                if element is not None:
                    if self.handle is not None and not element.isNull():
                        self.linkCredit = unwrapper.unwrapUInt(element)
                    else:
                        raise ValueError(
                            "Received malformed Flow header: link-credit can't be present when handle is null"
                        )
            if size > 7:
                element = list.getList()[7]
                if element is not None:
                    if self.handle is not None and not element.isNull():
                        self.available = unwrapper.unwrapUInt(element)
                    else:
                        raise ValueError(
                            "Received malformed Flow header: available can't be present when handle is null"
                        )
            if size > 8:
                element = list.getList()[8]
                if element is not None:
                    if self.handle is not None and not element.isNull():
                        self.drain = unwrapper.unwrapBool(element)
                    else:
                        raise ValueError(
                            "Received malformed Flow header: drain can't be present when handle is null"
                        )
            if size > 9:
                element = list.getList()[9]
                if element is not None and not element.isNull():
                    self.echo = unwrapper.unwrapBool(element)
            if size > 10:
                element = list.getList()[10]
                if element is not None and not element.isNull():
                    self.properties = unwrapper.unwrapMap(element)
Exemplo n.º 13
0
 def fill(self, value):
     unwrapper = AMQPUnwrapper()
     if value is not None:
         self.data = unwrapper.unwrapBinary(value)
    def fromArgumentsList(self, list):
        unwrapper = AMQPUnwrapper()
        if isinstance(list, TLVList):
            size = len(list.getList())
            if size  == 0:
                raise ValueError("Received malformed Open header: container id can't be null")
            if size > 10:
                raise ValueError("Received malformed Open header. Invalid number of arguments: " + str(size))

            element = list.getList()[0]

            if element is None:
                raise ValueError("Received malformed Open header: container id can't be null")
            self.containerId = unwrapper.unwrapString(element)

            if size > 1:
                element = list.getList()[1]
                if element is not None and not element.isNull():
                    self.hostname = unwrapper.unwrapString(element)
            if size > 2:
                element = list.getList()[2]
                if element is not None and not element.isNull():
                    self.maxFrameSize = unwrapper.unwrapUInt(element) 
            if size > 3:
                element = list.getList()[3]
                if element is not None and not element.isNull():
                    self.channelMax = unwrapper.unwrapUShort(element)
            if size > 4:
                element = list.getList()[4]
                if element is not None and not element.isNull():
                    self.idleTimeout = unwrapper.unwrapUInt(element)
            if size > 5:
                element = list.getList()[5]
                if element is not None and not element.isNull():
                    self.outgoingLocales = unwrapper.unwrapArray(element)
            if size > 6:
                element = list.getList()[6]
                if element is not None and not element.isNull():
                    self.incomingLocales = unwrapper.unwrapArray(element)
            if size > 7:
                element = list.getList()[7]
                if element is not None and not element.isNull():
                    self.offeredCapabilities = unwrapper.unwrapArray(element)
            if size > 8:
                element = list.getList()[8]
                if element is not None and not element.isNull():
                    self.desiredCapabilities = unwrapper.unwrapArray(element)
            if size > 9:
                element = list.getList()[9]
                if element is not None and not element.isNull():
                    self.properties = unwrapper.unwrapMap(element)