RASCSI/python/common/src
Daniel Markstedt 2184992ce7
Tentative Web UI for the Printer device. (#676)
* Tentative Web UI for the Printer device.

* timeout must be a positive value

* Change the attach device class method to accept a dict with arbitrary key value pairs of parameters to be passed to the protobuf interface, rather than hard coded ones. Also renames the RaCtlCmds.attach_image() class method to attach_device().

* Make download_to_iso() use the new attach interface.

* Dynamically get the form items for support devices.

* Change the data structure returned by RaCtlCmds.get_device_types() to a dict, which contains the supported parameters and their default values. Leverage this data in the web ui to derive the form fields from the capabilities of rascsi.

* Tweak UI labels.

* Update FileCmds.read_config() to work with the new RaCtlCmds.attach_device() method.

* Check for numeric value.

* Streamline the UI for support devices.

* Handle support devices better by the oled screen.

* Clean up html.

* Dynamically adjust form field size based on data length.
2022-02-19 09:04:14 +01:00
..
rascsi Tentative Web UI for the Printer device. (#676) 2022-02-19 09:04:14 +01:00
__init__.py restructuring towards python client library #455 (#613) 2022-01-21 15:08:29 -08:00
README.md restructuring towards python client library #455 (#613) 2022-01-21 15:08:29 -08:00

RaSCSI Common Python Module

The common module contains python modules that are shared among multiple Python applications such as the OLED or the Web application. It contains shared functionality. For example, the rascsi python module provides functionality for accessing rascsi through its protobuf interface and provides convenient classes for that purpose.

Usage

To make use of the rascsi python module, it needs to be found by the Python scripts using it. This can be achieved in multiple ways. One way is to simply adapt the PYTHONPATH environment variable to include the common/src directory:

PYTHON_COMMON_PATH=${path_to_common_directory}/common/src
export PYTHONPATH=$PWD:${PYTHON_COMMON_PATH}
python3 myapp.py

The most interesting functions are likely found in the classes RaCtlCmds and FileCmds. Classes can be instantiated, for example, as follows (assuming that rascsi host, rascsi port and token are somehow retrieved from a command line argument):

sock_cmd = SocketCmds(host=args.rascsi_host, port=args.rascsi_port)
ractl_cmd = RaCtlCmds(sock_cmd=sock_cmd, token=args.token)

Usage examples can be found in the existing RaSCSI Python applications.