vanous/python-psn
1
0
Fork
You've already forked python-psn
0
Python only parsing library for PSN, PosiStageNet https://posistage.net/
Python 100%
Find a file
2023年04月14日 18:41:34 +02:00
.github/workflows initial commit 2023年04月05日 19:36:44 +02:00
examples Add start/stop methods, complete trigger example 2023年04月14日 18:41:34 +02:00
pypsn Add start/stop methods, complete trigger example 2023年04月14日 18:41:34 +02:00
tests Add info packet data, new tests, new test data 2023年04月07日 11:54:30 +02:00
.gitignore initial commit 2023年04月05日 19:36:44 +02:00
conftest.py initial commit 2023年04月05日 19:36:44 +02:00
LICENSE initial commit 2023年04月05日 19:36:44 +02:00
README.md Add start/stop methods, complete trigger example 2023年04月14日 18:41:34 +02:00
setup.py initial commit 2023年04月05日 19:36:44 +02:00

python-psn

Python only parsing library for PSN V2 - PosiStageNet

PSN specification as per GitHub repo

Installation

To install from git, run pip:

python -m pip install https://codeload.github.com/open-stage/python-psn/zip/refs/heads/master

Usage

import pypsn
# define a callback function
def callback_function(data):
 if isinstance(data, pypsn_module.psn_data_packet): # packet type: psn.psn_data_packet
 for tracker in data.trackers: # loop through all trackers
 print(tracker.pos) # print the received coordinates
 if isinstance(data, pypsn_module.psn_info_packet): # packet type: psn.psn_info_packet
 print(data.name) # print server name
 for tracker in data.trackers: # loop through all trackers
 print(tracker.tracker_name) # print the received tracker name
# provide a callback function and an IP address
receiver = pypsn.receiver(callback_function, "10.0.0.1")
receiver.start() # start the receiving thread
receiver.stop() # stop receiving

See examples folder for some more examples.

Development, status

  • Supporting PSN V2
  • Parsing only, not sending
  • Using threading module
  • Linux, Windows and macOS tested
  • Typed
  • Initial pytest testing provided together with CI/CD setup

Type hints

  • At this point, the --no-strict-optional is needed for mypy tests to pass:
mypy pypsn/*py --pretty --no-strict-optional

Format

  • to format, use black

Testing

  • to test, use pytest
  • to test typing with mypy use
pytest --mypy -m mypy pypsn/*py