Skip to content

Latest commit

 

History

History
50 lines (36 loc) · 1.47 KB

File metadata and controls

50 lines (36 loc) · 1.47 KB

PTT Python Example Plugin

Description

Barebones example plugin written in Python for PTT that will load an HTML index page and stream ticks using SSE.

Installation

After creating a venv in whatever way you feel like:

  1. Install dependencies:
    pip install -r requirements.txt
  2. Run main.py, output should be the handshake message:
    1|1|tcp|127.0.0.1:50051|grpc

Usage

  1. Generate the .plugin executable file (pyinstaller example):
    pyinstaller --onefile --name example.plugin main.py
  2. Move executable file to PTT plugins folder
  3. Launch PTT and select 'Python Example Plugin' from Web UI.

Protobuf Notes

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.proto

After 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__pb2

to:

from . import module_pb2 as module__pb2

For 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.