Skip to main content

A high-performance Python client for real-time management of XTables network tables, designed for robotics and complex data-driven systems.

Project description

XTablesClient

XTablesClient is a Python client designed for managing XTABLES, making it easier to handle real-time data in distributed systems, such as robotics applications or other environments where real-time communication is critical. This package supports data manipulation, subscriptions for updates, and communication with servers using socket connections and mDNS discovery.

Features

  • Automatically discovers services using mDNS (Zeroconf).
  • Supports sending and receiving various data types (e.g., booleans, strings, integers, arrays, bytes, and classes).
  • Provides efficient mechanisms for handling network table updates.
  • Allows subscription to updates for specific keys.
  • Robust reconnection mechanism and socket management.

Installation

  1. Clone or download the project.
  2. Install dependencies using the provided requirements.txt:
pip install -r requirements.txt
  1. Import the client into your project:
from XTablesClient import XTablesClient

Initialization

To initialize the client, you can provide the server's IP and port if known. If not provided, the client will automatically discover services using mDNS.

client = XTablesClient(server_ip="192.168.0.1", server_port=1735)

Methods

1. initialize_client(server_ip, server_port)

Connects to the server and starts a message listener for handling incoming messages.

Usage:

client.initialize_client("192.168.0.1", 1735)

2. send_data(data)

Sends data to the server over the socket connection.

Usage:

client.send_data("PUT key value")

3. executePutBoolean(key, value)

Sends a boolean value associated with the given key to the server.

Usage:

client.executePutBoolean("is_active", True)

4. executePutString(key, value)

Sends a string value associated with the given key to the server.

Usage:

client.executePutString("robot_name", "XTABLES")

5. executePutInteger(key, value)

Sends an integer value associated with the given key to the server.

Usage:

client.executePutInteger("robot_id", 123)

6. executePutFloat(key, value)

Sends a float value associated with the given key to the server.

Usage:

client.executePutFloat("battery_voltage", 12.5)

7. executePutBytes(key, value)

Sends a byte array encoded as a Base64 string to the server.

Usage:

client.executePutBytes("file_data", b'some_byte_data')

8. executePutArrayOrTuple(key, value)

Sends an array or tuple associated with the given key to the server.

Usage:

client.executePutArrayOrTuple("sensor_data", [1, 2, 3, 4])

9. executePutClass(key, obj)

Serializes a class object into a JSON string and sends it to the server.

Usage:

client.executePutClass("robot_status", status_object)

10. getBytes(key, TIMEOUT=3000)

Retrieves a Base64-encoded string from the server and decodes it back into a byte array.

Usage:

byte_data = client.getBytes("file_data")

11. getData(command, value=None, TIMEOUT=3000)

Sends a general request to the server and retrieves the response.

Usage:

response = client.getData("GET", "robot_name")

12. getString(key, TIMEOUT=3000)

Retrieves a string value associated with the given key.

Usage:

robot_name = client.getString("robot_name")

13. getTables(key=None, TIMEOUT=3000)

Retrieves the list of tables from the server.

Usage:

tables = client.getTables()

14. getArray(key, TIMEOUT=3000)

Retrieves an array (list) from the server for the given key.

Usage:

sensor_data = client.getArray("sensor_data")

15. getFloat(key, TIMEOUT=3000)

Retrieves a float value from the server for the given key.

Usage:

voltage = client.getFloat("battery_voltage")

16. getBoolean(key, TIMEOUT=3000)

Retrieves a boolean value from the server for the given key.

Usage:

is_active = client.getBoolean("is_active")

17. getInteger(key, TIMEOUT=3000)

Retrieves an integer value from the server for the given key.

Usage:

robot_id = client.getInteger("robot_id")

18. getClass(key, class_type, TIMEOUT=3000)

Retrieves a class object from the server, deserializing it from a JSON string.

Usage:

robot_status = client.getClass("robot_status", StatusClass)

19. getValue(key, TIMEOUT=3000)

Retrieves a value from the server and returns it in its appropriate Python type (e.g., list, dict, int, float, etc.).

Usage:

value = client.getValue("robot_status")

20. subscribeForUpdates(key, consumer)

Subscribes for updates for a specific key and registers a consumer to handle update events.

Usage:

client.subscribeForUpdates("robot_name", update_handler)

21. subscribeForAllUpdates(consumer)

Subscribes for updates for all keys and registers a consumer to handle update events.

Usage:

client.subscribeForAllUpdates(update_handler)

22. deleteTable(key=None)

Deletes a table or specific key from the server.

Usage:

status = client.deleteTable("robot_table")

23. updateKey(oldKey, newKey)

Renames a key in the server.

Usage:

status = client.updateKey("old_robot_name", "new_robot_name")

24. rebootServer()

Reboots the server.

Usage:

status = client.rebootServer()

25. resubscribe_all()

Re-subscribes to all previously subscribed keys after reconnection.

Usage:

client.resubscribe_all()

26. shutdown()

Shuts down the client, stopping all listeners and closing the socket connection.

Usage:

client.shutdown()

License

This project is licensed under the MIT License.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

XTablesClient-1.0.2.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

XTablesClient-1.0.2-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file XTablesClient-1.0.2.tar.gz.

File metadata

  • Download URL: XTablesClient-1.0.2.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for XTablesClient-1.0.2.tar.gz
Algorithm Hash digest
SHA256 8acc7677a218f2556466824fb3f96a09d1efef5ab996a3338041565255dee7eb
MD5 a1cf2d16a5a9b409a4e3e5f79fd5a2ae
BLAKE2b-256 947599635306b53a1f2fbd279404fdb6ac0335ab73f766d9309737b6cb42c566

See more details on using hashes here.

File details

Details for the file XTablesClient-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: XTablesClient-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for XTablesClient-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 91de432026d875c73afcb60d12b21726865928a27da4ed17d20bd7d9d8e5b2a6
MD5 113a5187a5558a35d5ccef67433aea54
BLAKE2b-256 d3790d7538735a0941baac1591afa5ec960a0b80ff9eb79378aa96a902ee7932

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