Barebones example plugin written in Python for PTT that will load an HTML index page and stream ticks using SSE.
After creating a venv in whatever way you feel like:
- Install dependencies:
pip install -r requirements.txt
- Run main.py, output should be the handshake message:
1|1|tcp|127.0.0.1:50051|grpc
- Generate the .plugin executable file (pyinstaller example):
pyinstaller --onefile --name example.plugin main.py
- Move executable file to PTT plugins folder
- Launch PTT and select 'Python Example Plugin' from Web UI.
To regenerate the .py files from module.proto, run this command in the proto_files directory:
python3 -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. module.protoAfter generating the proto files, you have to manually edit the generated module_pb2_grpc.py file to fix package management issues. Specifically, change:
import module_pb2 as module__pb2to:
from . import module_pb2 as module__pb2For further reading into avoiding this horrible issue that will never be fixed:
- Protoletariat - fixes absolute import issues post generation.
- Betterproto - helps eliminate these issues altogether but would require refactoring.