kopia lustrzana https://github.com/glidernet/python-ogn-client
Rename package to python-ogn-client
rodzic
abae52b165
commit
ca77c45474
|
@ -1,6 +1,11 @@
|
||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
- The repository ogn-python splitted up into two separate repositories:
|
||||||
|
- python-ogn-client (the repository this Changelog belongs to),
|
||||||
|
including an APRS- & OGN-Parser, APRS-Client and DDB-Client.
|
||||||
|
- python-ogn-gateway, including a database, CLI, logbook.
|
||||||
|
|
||||||
- Moved exceptions from `ogn.exceptions` to `ogn.parser.exceptions`
|
- Moved exceptions from `ogn.exceptions` to `ogn.parser.exceptions`
|
||||||
- Moved parsing from `ogn.model.*` to `ogn.parser`
|
- Moved parsing from `ogn.model.*` to `ogn.parser`
|
||||||
|
|
||||||
|
|
69
README.md
69
README.md
|
@ -1,36 +1,33 @@
|
||||||
# ogn-python
|
# python-ogn-client
|
||||||
|
|
||||||
[]
|
[]
|
||||||
(https://travis-ci.org/glidernet/ogn-python)
|
(https://travis-ci.org/glidernet/python-ogn-client)
|
||||||
[]
|
[]
|
||||||
(https://coveralls.io/r/glidernet/ogn-python)
|
(https://coveralls.io/r/glidernet/python-ogn-client)
|
||||||
[]
|
|
||||||
(https://pypi.python.org/pypi/ogn-python)
|
|
||||||
|
|
||||||
A python module for the [Open Glider Network](http://wiki.glidernet.org/).
|
A python3 module for the [Open Glider Network](http://wiki.glidernet.org/).
|
||||||
The submodule 'ogn.gateway' is an aprs client which could be invoked via a CLI
|
It can be used to connect to the OGN-APRS-Servers and to parse APRS-/OGN-Messages.
|
||||||
or used by other python projects.
|
|
||||||
The CLI allows to save all received beacons into a database with [SQLAlchemy](http://www.sqlalchemy.org/).
|
|
||||||
The [sqlite](https://www.sqlite.org/)-backend is sufficient for simple testing,
|
|
||||||
but some tasks (e.g. logbook generation) require a proper backend like [postgresql](http://www.postgresql.org/).
|
|
||||||
An external python project would instantiate ogn.gateway and register a custom callback,
|
|
||||||
called each time a beacon is received.
|
|
||||||
|
|
||||||
[Examples](https://github.com/glidernet/ogn-python/wiki/Examples)
|
A full featured gateway with build-in database is provided by [py-ogn-gateway](https://github.com/glidernet/ogn-python).
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
## Example 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:
|
Parse APRS/OGN packet.
|
||||||
```python
|
|
||||||
#!/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
|
|
||||||
|
|
||||||
|
```
|
||||||
|
from ogn.parser import parse_aprs, parse_beacon
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
beacon = parse_aprs("FLRDDDEAD>APRS,qAS,EDER:/114500h5029.86N/00956.98E'342/049/A=005524 id0ADDDEAD -454fpm -1.1rot 8.8dB 0e +51.2kHz gps4x5",
|
||||||
|
reference_date=datetime(2016,1,1,11,46))
|
||||||
|
```
|
||||||
|
|
||||||
|
Connect to OGN and display all incoming beacons.
|
||||||
|
|
||||||
|
```
|
||||||
|
from ogn.client import ognClient
|
||||||
|
from ogn.parser import parse_aprs, parse_beacon, ParseError
|
||||||
|
|
||||||
def process_beacon(raw_message):
|
def process_beacon(raw_message):
|
||||||
if raw_message[0] == '#':
|
if raw_message[0] == '#':
|
||||||
|
@ -39,25 +36,21 @@ def process_beacon(raw_message):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
message = parse_aprs(raw_message)
|
message = parse_aprs(raw_message)
|
||||||
message.update(parse_ogn_beacon(message['comment']))
|
message.update(parse_beacon(message['comment']))
|
||||||
|
|
||||||
print('Received {beacon_type} from {name}'.format(**message))
|
print('Received {beacon_type} from {name}'.format(**message))
|
||||||
except ParseError as e:
|
except ParseError as e:
|
||||||
print('Error, {}'.format(e.message))
|
print('Error, {}'.format(e.message))
|
||||||
|
|
||||||
|
client = ognClient(aprs_user='N0CALL')
|
||||||
|
client.connect()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
try:
|
||||||
gateway = ognGateway(aprs_user='N0CALL')
|
client.run(callback=process_beacon, autoreconnect=True)
|
||||||
gateway.connect()
|
except KeyboardInterrupt:
|
||||||
|
print('\nStop ogn gateway')
|
||||||
try:
|
client.disconnect()
|
||||||
gateway.run(callback=process_beacon, autoreconnect=True)
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
print('\nStop ogn gateway')
|
|
||||||
|
|
||||||
gateway.disconnect()
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
Licensed under the [AGPLv3](LICENSE).
|
Licensed under the [AGPLv3](LICENSE).
|
||||||
|
|
17
setup.py
17
setup.py
|
@ -3,7 +3,7 @@
|
||||||
from os import path
|
from os import path
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
from ogn.gateway.settings import PACKAGE_VERSION
|
from ogn.client.settings import PACKAGE_VERSION
|
||||||
|
|
||||||
|
|
||||||
here = path.abspath(path.dirname(__file__))
|
here = path.abspath(path.dirname(__file__))
|
||||||
|
@ -13,11 +13,11 @@ with open(path.join(here, 'README.md'), encoding='utf-8') as f:
|
||||||
long_description = f.read()
|
long_description = f.read()
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='ogn-python',
|
name='python-ogn-client',
|
||||||
version=PACKAGE_VERSION,
|
version=PACKAGE_VERSION,
|
||||||
description='A python module for the Open Glider Network',
|
description='A python module for the Open Glider Network',
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
url='https://github.com/glidernet/ogn-python',
|
url='https://github.com/glidernet/python-ogn-client',
|
||||||
author='Konstantin Gründger aka Meisterschueler, Fabian P. Schmidt aka kerel',
|
author='Konstantin Gründger aka Meisterschueler, Fabian P. Schmidt aka kerel',
|
||||||
author_email='kerel-fs@gmx.de',
|
author_email='kerel-fs@gmx.de',
|
||||||
license='AGPLv3',
|
license='AGPLv3',
|
||||||
|
@ -33,21 +33,12 @@ setup(
|
||||||
],
|
],
|
||||||
keywords='gliding ogn',
|
keywords='gliding ogn',
|
||||||
packages=find_packages(exclude=['tests', 'tests.*']),
|
packages=find_packages(exclude=['tests', 'tests.*']),
|
||||||
install_requires=[
|
install_requires=[],
|
||||||
'SQLAlchemy==1.0.8',
|
|
||||||
'geopy==1.11.0',
|
|
||||||
'manage.py==0.2.10',
|
|
||||||
'celery[redis]>=3.1,<3.2',
|
|
||||||
'alembic==0.8.3'
|
|
||||||
],
|
|
||||||
extras_require={
|
extras_require={
|
||||||
'dev': [
|
'dev': [
|
||||||
'nose==1.3.7',
|
'nose==1.3.7',
|
||||||
'coveralls==0.4.4',
|
'coveralls==0.4.4',
|
||||||
'flake8==2.5.0'
|
'flake8==2.5.0'
|
||||||
],
|
|
||||||
'postgresql': [
|
|
||||||
'psycopg2==2.6.1'
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
zip_safe=False
|
zip_safe=False
|
||||||
|
|
Ładowanie…
Reference in New Issue