2022-12-05 17:58:23 +00:00
|
|
|
# PiSCSI Common Python Module
|
2022-01-21 23:08:29 +00:00
|
|
|
|
|
|
|
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.
|
2022-12-05 17:58:23 +00:00
|
|
|
For example, the piscsi python module provides functionality for accessing piscsi through its
|
2022-01-21 23:08:29 +00:00
|
|
|
protobuf interface and provides convenient classes for that purpose.
|
|
|
|
|
|
|
|
### Usage
|
|
|
|
|
2022-12-05 17:58:23 +00:00
|
|
|
To make use of the piscsi python module, it needs to be found by the Python scripts using it.
|
2022-01-21 23:08:29 +00:00
|
|
|
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
|
|
|
|
```
|
|
|
|
|
2022-12-05 17:58:23 +00:00
|
|
|
The most interesting functions are likely found in the classes PiscsiCmds and FileCmds. Classes
|
2022-01-21 23:08:29 +00:00
|
|
|
can be instantiated, for example, as follows
|
2022-12-05 17:58:23 +00:00
|
|
|
(assuming that piscsi host, piscsi port and token are somehow retrieved from a command line
|
2022-01-21 23:08:29 +00:00
|
|
|
argument):
|
|
|
|
|
|
|
|
```
|
2022-12-05 17:58:23 +00:00
|
|
|
sock_cmd = SocketCmds(host=args.piscsi_host, port=args.piscsi_port)
|
|
|
|
piscsi_cmd = PiscsiCmds(sock_cmd=sock_cmd, token=args.token)
|
2022-01-21 23:08:29 +00:00
|
|
|
```
|
|
|
|
|
2022-12-05 17:58:23 +00:00
|
|
|
Usage examples can be found in the existing PiSCSI Python applications.
|