GithubHelp home page GithubHelp logo

Comments (4)

arthall avatar arthall commented on August 13, 2024

Thank you for bringing this to our attention.

The baseclient doesn't allow bytes in this case, because the API specifies the values as string. https://docs.cloud.oracle.com/iaas/api/#/en/streaming/20180418/datatypes/PutMessagesDetailsEntry

I've tested the following changes in Python 2.7.12, 3.5.1 and 3.7.2 and they work in all three environments.

First, I imported encode and decode from the codecs package.

from codecs import encode, decode

Then changed the encoding of the key and message to

        encoded_key = encode(key.encode(), "base-64").decode().strip()
        encoded_value = encode(value.encode(), "base-64").decode().strip()

and changed the reading of the messages to

        for message in get_response.data:
            print("{}: {}".format(decode(message.key.encode(), "base64").decode(),
                                  decode(message.value.encode(), "base64").decode()))

Not related encodings, but also updated the line where the stream is deleted.

client.delete_stream_and_wait_for_state(stream_id, wait_for_states=[oci.streaming.models.StreamSummary.LIFECYCLE_STATE_DELETED])

Some of the encoding and decoding isn't required, but it keeps the results consistent between Python 2 and Python 3. I haven't tried to use unicode in my test, and there may be more steps required in that case. I'll update the example for the next release.

from oci-python-sdk.

miles182 avatar miles182 commented on August 13, 2024

Thanks for the fast response I really appreciate it. I just changed the example using codecs package, that indeed works.

from oci-python-sdk.

arthall avatar arthall commented on August 13, 2024

The example has been updated with the latest release. Thanks again @miles182 for pointing out the issue.

from oci-python-sdk.

arthall avatar arthall commented on August 13, 2024

The solution presented here introduces a bug if the key or value is too long. See #147.

from oci-python-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.