2015-11-15 07:56:36 +00:00
|
|
|
# ogn-python
|
2015-10-24 21:13:21 +00:00
|
|
|
|
2015-11-18 21:56:46 +00:00
|
|
|
[![Build Status](https://travis-ci.org/glidernet/ogn-python.svg?branch=master)]
|
|
|
|
(https://travis-ci.org/glidernet/ogn-python)
|
|
|
|
[![Coverage Status](https://img.shields.io/coveralls/glidernet/ogn-python.svg)]
|
|
|
|
(https://coveralls.io/r/glidernet/ogn-python)
|
2016-02-17 19:20:58 +00:00
|
|
|
[![PyPi Version](https://img.shields.io/pypi/v/ogn-python.svg)]
|
|
|
|
(https://pypi.python.org/pypi/ogn-python)
|
2015-11-15 08:26:09 +00:00
|
|
|
|
2016-03-18 21:56:59 +00:00
|
|
|
A database backend for the [Open Glider Network](http://wiki.glidernet.org/).
|
|
|
|
The ogn-python module saves all received beacons into a database with [SQLAlchemy](http://www.sqlalchemy.org/).
|
|
|
|
It connects to the OGN aprs servers with [python-ogn-client](https://github.com/glidernet/python-ogn-client).
|
2016-05-22 05:11:58 +00:00
|
|
|
It requires [PostgreSQL](http://www.postgresql.org/) and [PostGIS](http://www.postgis.net/).
|
2016-01-12 18:31:08 +00:00
|
|
|
|
|
|
|
[Examples](https://github.com/glidernet/ogn-python/wiki/Examples)
|
|
|
|
|
|
|
|
|
2016-03-18 21:54:22 +00:00
|
|
|
## Installation and Setup
|
2016-01-12 18:31:08 +00:00
|
|
|
1. Checkout the repository
|
|
|
|
|
|
|
|
```
|
|
|
|
git clone https://github.com/glidernet/ogn-python.git
|
|
|
|
```
|
|
|
|
|
|
|
|
2. Install python requirements
|
2015-12-05 09:04:26 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
pip install -r requirements.txt
|
|
|
|
```
|
2015-11-15 08:26:09 +00:00
|
|
|
|
2016-01-12 18:31:08 +00:00
|
|
|
3. Install redis for asynchronous tasks (like takeoff/landing-detection)
|
2015-12-05 09:04:26 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
apt-get install redis-server
|
|
|
|
```
|
2015-11-15 08:26:09 +00:00
|
|
|
|
2016-01-12 18:31:08 +00:00
|
|
|
4. Create database
|
2015-12-05 09:04:26 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
./manage.py db.init
|
|
|
|
```
|
2015-11-15 08:26:09 +00:00
|
|
|
|
2016-03-18 21:54:22 +00:00
|
|
|
## Usage
|
2016-01-12 18:31:08 +00:00
|
|
|
### Running the aprs client and task server
|
|
|
|
To schedule tasks like takeoff/landing-detection (`logbook.compute`),
|
|
|
|
[Celery](http://www.celeryproject.org/) with [Redis](http://www.redis.io/) is used.
|
|
|
|
The following scripts run in the foreground and should be deamonized
|
2015-11-15 08:26:09 +00:00
|
|
|
(eg. use [supervisord](http://supervisord.org/)).
|
|
|
|
|
2016-01-29 04:33:59 +00:00
|
|
|
- Start the aprs client
|
2016-01-12 18:31:08 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
./manage.py gateway.run
|
|
|
|
```
|
|
|
|
|
2016-01-29 04:33:59 +00:00
|
|
|
- Start a task server (make sure redis is up and running)
|
2015-11-15 08:26:09 +00:00
|
|
|
|
2016-01-12 18:31:08 +00:00
|
|
|
```
|
|
|
|
celery -A ogn.collect worker -l info
|
|
|
|
```
|
|
|
|
|
2016-01-29 04:33:59 +00:00
|
|
|
- Start the task scheduler (make sure a task server is up and running)
|
|
|
|
|
|
|
|
```
|
|
|
|
celery -A ogn.collect beat -l info
|
|
|
|
```
|
|
|
|
|
|
|
|
|
2016-01-29 01:34:12 +00:00
|
|
|
To load a custom configuration, create a file `myconfig.py` (see [config/default.py](config/default.py))
|
|
|
|
and set the environment variable `OGN_CONFIG_MODULE` accordingly.
|
|
|
|
|
|
|
|
```
|
2016-02-04 22:15:54 +00:00
|
|
|
touch myconfig.py
|
|
|
|
export OGN_CONFIG_MODULE="myconfig"
|
2016-01-29 01:34:12 +00:00
|
|
|
./manage.py gateway.run
|
|
|
|
```
|
|
|
|
|
2016-01-12 18:31:08 +00:00
|
|
|
### manage.py - CLI options
|
2015-11-15 08:26:09 +00:00
|
|
|
```
|
|
|
|
usage: manage.py [<namespace>.]<command> [<args>]
|
|
|
|
|
|
|
|
positional arguments:
|
|
|
|
command the command to run
|
|
|
|
|
|
|
|
optional arguments:
|
|
|
|
-h, --help show this help message and exit
|
|
|
|
|
|
|
|
available commands:
|
|
|
|
|
|
|
|
[db]
|
2016-01-12 18:31:08 +00:00
|
|
|
drop Drop all tables.
|
2016-04-28 14:39:02 +00:00
|
|
|
import_airports Import airports from a ".cup" file
|
2015-12-09 02:41:58 +00:00
|
|
|
import_ddb Import registered devices from the DDB.
|
2016-01-12 18:31:08 +00:00
|
|
|
import_file Import registered devices from a local file.
|
2015-11-15 08:26:09 +00:00
|
|
|
init Initialize the database.
|
2016-01-31 01:25:21 +00:00
|
|
|
upgrade Upgrade database to the latest version.
|
2015-12-09 02:41:58 +00:00
|
|
|
|
2015-11-15 08:26:09 +00:00
|
|
|
[gateway]
|
|
|
|
run Run the aprs client.
|
2015-12-09 02:37:25 +00:00
|
|
|
|
2015-11-15 08:26:09 +00:00
|
|
|
[logbook]
|
2015-11-26 07:35:41 +00:00
|
|
|
compute Compute takeoffs and landings.
|
2016-04-28 14:39:02 +00:00
|
|
|
show Show a logbook for <airport_name>.
|
2015-12-09 02:37:25 +00:00
|
|
|
|
2016-06-04 07:15:57 +00:00
|
|
|
[show.airport]
|
|
|
|
list_all Show a list of all airports.
|
|
|
|
|
2015-12-09 02:37:25 +00:00
|
|
|
[show.devices]
|
|
|
|
stats Show some stats on registered devices.
|
|
|
|
|
2015-11-15 08:26:09 +00:00
|
|
|
[show.receiver]
|
|
|
|
hardware_stats Show some statistics of receiver hardware.
|
2016-02-04 17:33:16 +00:00
|
|
|
list_all Show a list of all receivers.
|
2015-11-15 11:13:56 +00:00
|
|
|
software_stats Show some statistics of receiver software.
|
2015-11-15 08:26:09 +00:00
|
|
|
```
|
|
|
|
|
2015-12-09 02:41:58 +00:00
|
|
|
Only the command `logbook.compute` requires a running task server (celery) at the moment.
|
2015-11-15 08:26:09 +00:00
|
|
|
|
|
|
|
|
2016-01-29 04:33:59 +00:00
|
|
|
### Available tasks
|
2015-11-15 08:26:09 +00:00
|
|
|
|
2016-02-04 22:05:32 +00:00
|
|
|
- `ogn.collect.database.import_ddb` - Import registered devices from the ddb
|
|
|
|
- `ogn.collect.database.import_file` - Import registered devices from a local file
|
2016-06-04 07:15:57 +00:00
|
|
|
- `ogn.collect.receiver.update_receivers` - Populate/update receiver table
|
|
|
|
- `ogn.collect.logbook.compute_takeoff_and_landing` - Generate TakeoffLanding table
|
2016-02-04 22:05:32 +00:00
|
|
|
|
|
|
|
If the task server is up and running, tasks could be started manually.
|
|
|
|
|
|
|
|
```
|
|
|
|
python3
|
|
|
|
>>>from ogn.collect.database import import_ddb
|
|
|
|
>>>import_ddb.delay()
|
|
|
|
```
|
2015-11-15 08:26:09 +00:00
|
|
|
|
2016-01-12 18:31:08 +00:00
|
|
|
## License
|
|
|
|
Licensed under the [AGPLv3](LICENSE).
|