Skip to main content

Python bindings for the OUCH protocol

Project description

This package is python extension module for rust crate ouch_connect_nonblocking

Installation & Test

  • pytest expects ouch_connect source to be checked out from github. Test files are located in ./bindings/python/tests directory.
micromamba create --name ouch_pypi_env --yes python &&
micromamba run --name ouch_pypi_env pip install "ouch-connect[test]>=5.0,<5.1" &&
micromamba run --name ouch_pypi_env pytest

Basic Usage Example

import logging
from time import sleep
from ouch_connect import CltAuto, SvcAuto
from links_connect.callbacks import LoggerCallback, DecoratorDriver, on_recv, on_sent, MemoryStoreCallback


logging.basicConfig(format="%(asctime)-15s [%(threadName)10s|%(levelname)8s] %(message)s \t%(filename)s:%(lineno)d")
logging.getLogger().setLevel(logging.INFO)
log = logging.getLogger(__name__)
addr = "127.0.0.1:8080"

class SimulatorExample(DecoratorDriver):
    @on_recv({"Dbg": {}})
    def on_dbg(self, con_id, msg):
        self.sender.send({"Dbg": {"text": "Hello from Simulator"}})

    @on_recv({})
    def on_all_recv(self, con_id, msg):
        pass

    @on_sent({})
    def on_all_sent(self, con_id, msg):
        pass

store = MemoryStoreCallback()
clt_clbk = LoggerCallback(sent_level=logging.NOTSET) + store
svc_clbk = SimulatorExample() + store
with (
    SvcAuto(addr, svc_clbk, **dict(name="svc-ouch")) as svc,
    CltAuto(addr, clt_clbk, **dict(name="clt-ouch")) as clt,
):
    assert clt.is_connected() and svc.is_connected()

    log.info(f"svc: {svc}")
    log.info(f"clt: {clt}")

    clt.send({"Dbg": {"text": "Hello from Clt"}})

    found = store.find_recv(name="svc-ouch", filter={"Dbg":{}})
    assert found is not None and found.msg["Dbg"]["text"] == "Hello from Clt"
    log.info(f"found: {found}")

    found = store.find_recv(name="clt-ouch", filter={"Dbg":{}})
    assert found is not None and found.msg["Dbg"]["text"] == "Hello from Simulator"
    log.info(f"found: {found}")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ouch_connect-5.0.1-cp310-abi3-win_amd64.whl (680.9 kB view details)

Uploaded CPython 3.10+Windows x86-64

ouch_connect-5.0.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

ouch_connect-5.0.1-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (2.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ s390x

ouch_connect-5.0.1-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.8 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ppc64le

ouch_connect-5.0.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.7 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

ouch_connect-5.0.1-cp310-abi3-macosx_11_0_arm64.whl (863.4 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

ouch_connect-5.0.1-cp310-abi3-macosx_10_12_x86_64.whl (857.2 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file ouch_connect-5.0.1-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for ouch_connect-5.0.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 30e2aaebac53151b59f1c53e6b997fc1213d5c90d0d10e6868e14ac9d8898760
MD5 a43577a55418c32069320de6da57a749
BLAKE2b-256 b961ab48d6e7d92b55cdf84682bddef2ec072595e0dddda4bad7c1617f5cf17a

See more details on using hashes here.

File details

Details for the file ouch_connect-5.0.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ouch_connect-5.0.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2ac22ba683e64421f69412c165fb5be26d9c3e56ed0ef905e4b20a9f7388ecb3
MD5 0cd2888b1728f2e1eba9e83346ae8fd4
BLAKE2b-256 c0c32f3da184ba9b492f6acc5f9165d4bcc30e36f816174f13bf7ffe25ab4566

See more details on using hashes here.

File details

Details for the file ouch_connect-5.0.1-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for ouch_connect-5.0.1-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 e5bb31be82c8be9f1c3d66f063d14a9cc13a54a6368f1f10455d995d7ef6b1ef
MD5 07cdf3ee1d8d0504065dab76aeaa4abd
BLAKE2b-256 c7084cb2c41d16fc3e81a239fef0f645bc7e86a7236ada8bb683d51a6634431a

See more details on using hashes here.

File details

Details for the file ouch_connect-5.0.1-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for ouch_connect-5.0.1-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 4d266e4b622531ef105edc44d9a3e265b803f04e97b84eba15640630c9cb01ab
MD5 eba1292bcd7b9ab87a9526fbebf967ba
BLAKE2b-256 c99380cdfac872c5e12ff8616915d5f6ac913db8f72d8d87b9eae8b4bb3fe1ff

See more details on using hashes here.

File details

Details for the file ouch_connect-5.0.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ouch_connect-5.0.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 99e263c5f4f1fd7a1438894eb0c9ceb2b9534e778af15854e779ba02082da01e
MD5 272b560b3859f0b6bf53721bbf8292aa
BLAKE2b-256 4b45e2a07cbc73e766d36a82830bd06195d53b8ff0a99a693235e637679f8ec5

See more details on using hashes here.

File details

Details for the file ouch_connect-5.0.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ouch_connect-5.0.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3701e96c8128d52c2a0428917d0e8f2d96820055dabde3c3cdcce4eab1cfb0dc
MD5 1d46ed47473aaf4f76aa97475ec632b7
BLAKE2b-256 6946b945e4d3aa6bfd122a8b5a34d245e80a2349af4ed756b26e60166b400b98

See more details on using hashes here.

File details

Details for the file ouch_connect-5.0.1-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ouch_connect-5.0.1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d3bc82bee0e55f0d5411273fc3c8075319f89568cb65acd0e4877bc91bc35687
MD5 7bbd5304bc7afadf2a8892e44120594b
BLAKE2b-256 43a43606342474519cfb5227b8fd2dfddcc666d08f3e643db7e62fde6164e58f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page