mesh_client/__init__.py
def send_message(self,
                     recipient,
                     data,
                     **kwargs):
        """
        Send a message to recipient containing data.

        This method optionally allows the user to provide the following keyword
        arguments, which specify properties of the message, and map to
        the equivalent properties in MESH - either headers or control file
        entries, depending on the type of consumer:

        workflow_id
        filename
        local_id
        message_type
        process_id
        subject
        encrypted
        compressed
        checksum
        sender
        recipient
        message_id
        version
        partner_id
        recipient_smtp
        sender_smtp

        Note that compressed refers to *non-transparent* compression - the
        client will not attempt to compress or decompress data. Transparent
        compression for sending is enabled as a constructor option.
        """
        transparent_compress = self._transparent_compress
        maybe_compressed = (
            lambda stream: GzipCompressStream(
                stream) if transparent_compress else stream
        )
        headers = self._headers({
            "Mex-From": self._mailbox,
            "Mex-To": recipient,
            "Mex-MessageType": 'DATA',
            "Mex-Version": '1.0'
        })

        for key, value in kwargs.items():
            if key in _OPTIONAL_HEADERS:
                headers[_OPTIONAL_HEADERS[key]] = str(value)
            else:
                raise TypeError("Unrecognised keyword argument {key}."
                                " optional arguments are: {args}".format(
                                    key=key,
                                    args=", ".join([
                                        "recipient", "data"
                                    ] + list(_OPTIONAL_HEADERS.keys()))))

        if transparent_compress:
            headers["Mex-Content-Compress"] = "TRUE"
            headers["Content-Encoding"] = "gzip"

        chunks = SplitStream(data, self._max_chunk_size)
        headers["Mex-Chunk-Range"] = "1:{}".format(len(chunks))
        chunk_iterator = iter(chunks)

        chunk1 = maybe_compressed(six.next(chunk_iterator))
        response1 = requests.post(
            "{}/messageexchange/{}/outbox".format(self._url, self._mailbox),
            data=chunk1,
            headers=headers,
            cert=self._cert,
            verify=self._verify,
            proxies=self._proxies)
        json_resp = response1.json()
        if response1.status_code == 417 or "errorDescription" in json_resp:
            raise MeshError(json_resp["errorDescription"], json_resp)
        message_id = json_resp["messageID"]

        for i, chunk in enumerate(chunk_iterator):
            data = maybe_compressed(chunk)

            if self.max_chunk_retries > 0:
                if hasattr(data, 'read'):
                    data = data.read()
                buf = BytesIO(data)
            else:
                buf = data

            chunk_num = i + 2
            headers = self._headers({
                "Content-Type": "application/octet-stream",
                "Mex-Chunk-Range": "{}:{}".format(chunk_num, len(chunks)),
                "Mex-From": self._mailbox,
            })
            if transparent_compress:
                headers["Mex-Content-Compress"] = "TRUE"
                headers["Content-Encoding"] = "gzip"

            response = None
            for i in range(self.max_chunk_retries + 1):
                if self.max_chunk_retries > 0:
                    buf.seek(0)

                # non-linear delay in terms of squares
                time.sleep(i**2)

                response = requests.post(
                    "{}/messageexchange/{}/outbox/{}/{}".format(
                        self._url, self._mailbox, message_id, chunk_num),
                    data=buf,
                    headers=headers,
                    cert=self._cert,
                    verify=self._verify,
                    proxies=self._proxies)

                # check other successful response codes
                if response.status_code == 200 or response.status_code == 202:
                    break
            else:
                response.raise_for_status()

        return message_id

        Send a message to recipient containing data.

        This method optionally allows the user to provide the following keyword
        arguments, which specify properties of the message, and map to
        the equivalent properties in MESH - either headers or control file
        entries, depending on the type of consumer:

        workflow_id
        filename
        local_id
        message_type
        process_id
        subject
        encrypted
        compressed
        checksum
        sender
        recipient
        message_id
        version
        partner_id
        recipient_smtp
        sender_smtp

        Note that compressed refers to *non-transparent* compression - the
        client will not attempt to compress or decompress data. Transparent
        compression for sending is enabled as a constructor option.
        
Send a message to recipient containing data.
This method optionally allows the user to provide the following keyword
arguments, which specify properties of the message, and map to
the equivalent properties in MESH - either headers or control file
entries, depending on the type of consumer.



Note that compressed refers to *non-transparent* compression - the
client will not attempt to compress or decompress data. Transparent
compression for sending is enabled as a constructor option.
Send a message to recipient containing data . This method optionally allows the user to provide the following keyword arguments which specify properties of the message and map to the equivalent properties in MESH - either headers or control file entries depending on the type of consumer . Note that compressed refers to * non - transparent * compression - the client will not attempt to compress or decompress data . Transparent compression for sending is enabled as a constructor option .
def send_message(self,
                     recipient,
                     data,
                     **kwargs):
        transparent_compress = self._transparent_compress
        maybe_compressed = (
            lambda stream: GzipCompressStream(
                stream) if transparent_compress else stream
        )
        headers = self._headers({
            "Mex-From": self._mailbox,
            "Mex-To": recipient,
            "Mex-MessageType": 'DATA',
            "Mex-Version": '1.0'
        })
        for key, value in kwargs.items():
            if key in _OPTIONAL_HEADERS:
                headers[_OPTIONAL_HEADERS[key]] = str(value)
            else:
                raise TypeError("Unrecognised keyword argument {key}."
                                " optional arguments are: {args}".format(
                                    key=key,
                                    args=", ".join([
                                        "recipient", "data"
                                    ] + list(_OPTIONAL_HEADERS.keys()))))
        if transparent_compress:
            headers["Mex-Content-Compress"] = "TRUE"
            headers["Content-Encoding"] = "gzip"
        chunks = SplitStream(data, self._max_chunk_size)
        headers["Mex-Chunk-Range"] = "1:{}".format(len(chunks))
        chunk_iterator = iter(chunks)
        chunk1 = maybe_compressed(six.next(chunk_iterator))
        response1 = requests.post(
            "{}/messageexchange/{}/outbox".format(self._url, self._mailbox),
            data=chunk1,
            headers=headers,
            cert=self._cert,
            verify=self._verify,
            proxies=self._proxies)
        json_resp = response1.json()
        if response1.status_code == 417 or "errorDescription" in json_resp:
            raise MeshError(json_resp["errorDescription"], json_resp)
        message_id = json_resp["messageID"]
        for i, chunk in enumerate(chunk_iterator):
            data = maybe_compressed(chunk)
            if self.max_chunk_retries > 0:
                if hasattr(data, 'read'):
                    data = data.read()
                buf = BytesIO(data)
            else:
                buf = data
            chunk_num = i + 2
            headers = self._headers({
                "Content-Type": "application/octet-stream",
                "Mex-Chunk-Range": "{}:{}".format(chunk_num, len(chunks)),
                "Mex-From": self._mailbox,
            })
            if transparent_compress:
                headers["Mex-Content-Compress"] = "TRUE"
                headers["Content-Encoding"] = "gzip"
            response = None
            for i in range(self.max_chunk_retries + 1):
                if self.max_chunk_retries > 0:
                    buf.seek(0)
                time.sleep(i**2)
                response = requests.post(
                    "{}/messageexchange/{}/outbox/{}/{}".format(
                        self._url, self._mailbox, message_id, chunk_num),
                    data=buf,
                    headers=headers,
                    cert=self._cert,
                    verify=self._verify,
                    proxies=self._proxies)
                if response.status_code == 200 or response.status_code == 202:
                    break
            else:
                response.raise_for_status()
        return message_id
def send_message ( self , recipient , data , ** kwargs ) : transparent_compress = self . _transparent_compress maybe_compressed = ( lambda stream : GzipCompressStream ( stream ) if transparent_compress else stream ) headers = self . _headers ( { "Mex-From" : self . _mailbox , "Mex-To" : recipient , "Mex-MessageType" : 'DATA' , "Mex-Version" : '1.0' } ) for key , value in kwargs . items ( ) : if key in _OPTIONAL_HEADERS : headers [ _OPTIONAL_HEADERS [ key ] ] = str ( value ) else : raise TypeError ( "Unrecognised keyword argument {key}." " optional arguments are: {args}" . format ( key = key , args = ", " . join ( [ "recipient" , "data" ] + list ( _OPTIONAL_HEADERS . keys ( ) ) ) ) ) if transparent_compress : headers [ "Mex-Content-Compress" ] = "TRUE" headers [ "Content-Encoding" ] = "gzip" chunks = SplitStream ( data , self . _max_chunk_size ) headers [ "Mex-Chunk-Range" ] = "1:{}" . format ( len ( chunks ) ) chunk_iterator = iter ( chunks ) chunk1 = maybe_compressed ( six . next ( chunk_iterator ) ) response1 = requests . post ( "{}/messageexchange/{}/outbox" . format ( self . _url , self . _mailbox ) , data = chunk1 , headers = headers , cert = self . _cert , verify = self . _verify , proxies = self . _proxies ) json_resp = response1 . json ( ) if response1 . status_code == 417 or "errorDescription" in json_resp : raise MeshError ( json_resp [ "errorDescription" ] , json_resp ) message_id = json_resp [ "messageID" ] for i , chunk in enumerate ( chunk_iterator ) : data = maybe_compressed ( chunk ) if self . max_chunk_retries > 0 : if hasattr ( data , 'read' ) : data = data . read ( ) buf = BytesIO ( data ) else : buf = data chunk_num = i + 2 headers = self . _headers ( { "Content-Type" : "application/octet-stream" , "Mex-Chunk-Range" : "{}:{}" . format ( chunk_num , len ( chunks ) ) , "Mex-From" : self . _mailbox , } ) if transparent_compress : headers [ "Mex-Content-Compress" ] = "TRUE" headers [ "Content-Encoding" ] = "gzip" response = None for i in range ( self . max_chunk_retries + 1 ) : if self . max_chunk_retries > 0 : buf . seek ( 0 ) time . sleep ( i ** 2 ) response = requests . post ( "{}/messageexchange/{}/outbox/{}/{}" . format ( self . _url , self . _mailbox , message_id , chunk_num ) , data = buf , headers = headers , cert = self . _cert , verify = self . _verify , proxies = self . _proxies ) if response . status_code == 200 or response . status_code == 202 : break else : response . raise_for_status ( ) return message_id
Send a message to recipient containing data.
Send a message to recipient containing data .
"""
        Send a message to recipient containing data.

        This method optionally allows the user to provide the following keyword
        arguments, which specify properties of the message, and map to
        the equivalent properties in MESH - either headers or control file
        entries, depending on the type of consumer:

        workflow_id
        filename
        local_id
        message_type
        process_id
        subject
        encrypted
        compressed
        checksum
        sender
        recipient
        message_id
        version
        partner_id
        recipient_smtp
        sender_smtp

        Note that compressed refers to *non-transparent* compression - the
        client will not attempt to compress or decompress data. Transparent
        compression for sending is enabled as a constructor option.
        """ # non-linear delay in terms of squares # check other successful response codes
self
recipient
data