How to use the oscpy.parser.read_bundle function in oscpy

To help you get started, we’ve selected a few oscpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kivy / oscpy / tests / test_parser.py View on Github external
pad = padded(len('#bundle'))
    data = struct.pack('>%isQ' % pad, b'#bundle', 1)

    tests = (
        message_1,
        message_2,
        message_1,
        message_2,
    )

    for source, msg, result in tests:
        msg = struct.pack('>%iB' % len(msg), *msg)
        assert read_message(msg)[::2] == result
        data += struct.pack('>i', len(msg)) + msg

    timetag, messages = read_bundle(data)
    for test, r in zip(tests, messages):
        assert (r[0], r[2]) == test[2]
github kivy / oscpy / tests / test_parser.py View on Github external
def test_format_bundle():
    bundle, stats = format_bundle((message_1[0], message_2[0]), timetag=None)

    assert struct.pack('>%iB' % len(message_1[1]), *message_1[1]) in bundle
    assert struct.pack('>%iB' % len(message_2[1]), *message_2[1]) in bundle

    timetag, messages = read_bundle(bundle)

    assert timetag == approx(time())
    assert len(messages) == 2
    assert messages[0][::2] == message_1[2]
    assert messages[1][::2] == message_2[2]

    assert stats.calls == 2
    assert stats.bytes == 72
    assert stats.params == 6
    assert stats.types['f'] == 3
    assert stats.types['i'] == 2
    assert stats.types['s'] == 1
github kivy / oscpy / tests / test_parser.py View on Github external
def test_read_broken_bundle():
    s = b'not a bundle'
    data = struct.pack('>%is' % len(s), s)
    with raises(ValueError):
        read_bundle(data)