Skip to main content

coolpackets

A python framework for sending and receiving custom packets

This is used for an extension to Ableton Live. I will add features as I need them for that project.

Usage example:

import socket
import time
from typing import Union, Optional, List

from coolpackets.packet import Packet, Connection, PacketManager


class MidiPacket(Packet):
    _packet_group = "mrs"
    _alias = "\x00"

    a = int
    b = Union[int, float]
    c_is_optional = Optional[int]

    def on_recv(self):
        print("RECEIVED MidiPacket!", self.a, self.b, self.c_is_optional)
        self.respond(UselessPacket(cool=["1", "2", "3"]))


class UselessPacket(Packet):
    _alias = "useless"
    # _dump = False

    cool = List[str]

    def on_recv(self):
        print("RECEIVED UselessPacket!")

    def encode(self) -> bytes:
        return b""

    @classmethod
    def decode(cls, data: bytes):
        return cls(cool=["nice", "cool"])


PacketManager.dump_packets("./packet_dumps/demo_packet_dump.py")


# setup
srv = socket.socket()
srv.bind(('', 9056))
srv.listen(1)

cli = socket.socket()
cli.connect(('localhost', 9056))
peer, addr = srv.accept()

conn1 = Connection(cli)
conn2 = Connection(peer, addr, {'mrs'})

# main logic
pck = MidiPacket(a=3, b=7.4)
conn1.send(pck, lambda p: print(f"RECEIVED RESPONSE: {p}"))

# time to process packets. Usually we wouldn't just close the sockets
time.sleep(.1)

# cleanup
conn1.close()
conn2.close()
srv.close()

print("Done")

Metadata

Release files for coolpackets 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for coolpackets 0.0.2
File Size Uploaded Provenance
coolpackets-0.0.2.tar.gz 4.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for coolpackets 0.0.2
File Interpreter ABI Platform
coolpackets-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 14.8 kB

Release files / coolpackets-0.0.2.tar.gz

Download URL coolpackets-0.0.2.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4643eb8922864087ff603742440ded26393e96290e128272aa07e823e793d2ca
BLAKE2b-256 checksum
How to use checksums
12b02dfe2705052994a596af556b3910a7a10304f0740bbe36d37ac285a8ac74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

Release files / coolpackets-0.0.2-py3-none-any.whl

Download URL coolpackets-0.0.2-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b9548705165509ea56f75457d63e72d5187ad0a5f471e6dd5db317763b246754
BLAKE2b-256 checksum
How to use checksums
288ca4fdf6d4dddb982a9fab773840a7bb400102e232a642e5b8f3339c952e63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

Security for coolpackets 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page