Skip to main content

XTables Client for managing XTABLES.

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.0.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.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: XTablesClient-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 bfb809b9412cf10a88f1e08434095ca18cd53b04c5ce66b5f6cfaceedd32b172
MD5 31f3d76ec8b19b27cb551bb7ce33cdc5
BLAKE2b-256 3502c3ddd4f31a73e82def6ed07c968aacc622c0d886b2fc25a04a1975aa38a1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: XTablesClient-1.0.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 85b917df609bf1ab347e8b6f25ced245acd5d5e537d9b43aa6dd2f1997aa7ec8
MD5 f01fcccd1ddd87145ff38cce3a957678
BLAKE2b-256 2508a3802d7689b1998255244306d880d3b74a324667cdd4fcce9d1e7b33ecc2

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