bf03ac39dd
The repository ogn-python splits up into two separate repositories. - python-ogn-client (the repository this commit belongs to): includes an APRS- and OGN-Parser, an APRS-Client and a DDB-Client. - python-ogn-gateway: includes a database, CLI, logbook. Import from glidernet/ogn-python, commit ba7ae37ef273aa5840719b31e4bca0c16d99eadd |
||
---|---|---|
ogn | ||
tests | ||
.gitignore | ||
.travis.yml | ||
CHANGELOG.md | ||
CONTRIBUTORS | ||
LICENSE | ||
MANIFEST.in | ||
README.md | ||
requirements.txt | ||
setup.cfg | ||
setup.py |
README.md
ogn-python
[] (https://travis-ci.org/glidernet/ogn-python) [] (https://coveralls.io/r/glidernet/ogn-python) [] (https://pypi.python.org/pypi/ogn-python)
A python module for the Open Glider Network. The submodule 'ogn.gateway' is an aprs client which could be invoked via a CLI or used by other python projects. The CLI allows to save all received beacons into a database with SQLAlchemy. The sqlite-backend is sufficient for simple testing, but some tasks (e.g. logbook generation) require a proper backend like postgresql. An external python project would instantiate ogn.gateway and register a custom callback, called each time a beacon is received.
Usage
Implement your own gateway by using ogn.gateway with a custom callback function. Each time a beacon is received, this function gets called and lets you process the incoming data.
Example:
#!/usr/bin/env python3
from ogn.gateway.client import ognGateway
from ogn.parser.parse import parse_aprs, parse_ogn_beacon
from ogn.parser.exceptions import ParseError
def process_beacon(raw_message):
if raw_message[0] == '#':
print('Server Status: {}'.format(raw_message))
return
try:
message = parse_aprs(raw_message)
message.update(parse_ogn_beacon(message['comment']))
print('Received {beacon_type} from {name}'.format(**message))
except ParseError as e:
print('Error, {}'.format(e.message))
if __name__ == '__main__':
gateway = ognGateway(aprs_user='N0CALL')
gateway.connect()
try:
gateway.run(callback=process_beacon, autoreconnect=True)
except KeyboardInterrupt:
print('\nStop ogn gateway')
gateway.disconnect()
License
Licensed under the AGPLv3.