ogn-python/README.md

159 wiersze
5.1 KiB
Markdown
Czysty Zwykły widok Historia

2015-11-15 07:56:36 +00:00
# ogn-python
2015-10-24 21:13:21 +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)
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).
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)
## 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
```
pip install -r requirements.txt
```
2016-06-16 08:58:03 +00:00
3. Install [PostgreSQL](http://www.postgresql.org/) with [PostGIS](http://www.postgis.net/) Extension.
Create a database (use "ogn" as default, otherwise you have to modify the configuration, see below)
2015-11-15 08:26:09 +00:00
2016-06-16 08:58:03 +00:00
4. Optional: Install redis for asynchronous tasks (like takeoff/landing-detection)
```
apt-get install redis-server
```
2015-11-15 08:26:09 +00:00
2016-06-16 08:58:03 +00:00
5. Create database
```
./manage.py db.init
```
2015-11-15 08:26:09 +00:00
There is also a [Vagrant](https://www.vagrantup.com/) environment for the development of ogn-python.
You can create and start this virtual machine with `vagrant up` and login with `vagrant ssh`.
The code of ogn-python will be available in the shared folder `/vagrant`.
## 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/)).
- Start the aprs client
2016-01-12 18:31:08 +00:00
```
./manage.py gateway.run
```
- 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
```
- Start the task scheduler (make sure a task server is up and running)
```
celery -A ogn.collect beat -l info
```
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.
```
touch myconfig.py
export OGN_CONFIG_MODULE="myconfig"
./manage.py gateway.run
```
2016-01-12 18:31:08 +00:00
### manage.py - CLI options
2015-11-15 08:26:09 +00:00
```
2017-06-23 06:16:45 +00:00
usage: manage [<namespace>.]<command> [<args>]
2015-11-15 08:26:09 +00:00
positional arguments:
command the command to run
optional arguments:
-h, --help show this help message and exit
available commands:
2017-06-23 06:16:45 +00:00
[bulkimport]
convert_logfile Convert ogn logfiles to csv logfiles (one for aircraft beacons and one for receiver beacons) <arg: path>. Logfile name: blablabla.txt_YYYY-MM-DD.
create_indices Create indices for AircraftBeacon.
drop_indices Drop indices of AircraftBeacon.
import_csv_logfile Import csv logfile <arg: csv logfile>.
2015-11-15 08:26:09 +00:00
[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
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.
2017-06-04 09:53:21 +00:00
update_relations Update AircraftBeacon and ReceiverBeacon relations
upgrade Upgrade database to the latest version.
2017-06-23 06:16:45 +00:00
2015-11-15 08:26:09 +00:00
[gateway]
run Run the aprs client.
2017-06-23 06:16:45 +00:00
[igcexport]
write Export igc file for <address> at <date>.
2015-11-15 08:26:09 +00:00
[logbook]
2016-07-14 19:15:58 +00:00
compute_logbook Compute logbook.
compute_takeoff_landingCompute takeoffs and landings.
2016-04-28 14:39:02 +00:00
show Show a logbook for <airport_name>.
2017-06-23 06:16:45 +00:00
2016-06-04 07:15:57 +00:00
[show.airport]
list_all Show a list of all airports.
2017-06-23 06:16:45 +00:00
2016-07-14 19:15:58 +00:00
[show.deviceinfos]
stats Show some stats on registered devices.
2017-06-23 06:16:45 +00:00
2016-07-14 19:15:58 +00:00
[show.devices]
aircraft_type_stats Show stats about aircraft types used by devices.
hardware_stats Show stats about hardware version used by devices.
software_stats Show stats about software version used by devices.
stealth_stats Show stats about stealth flag set by devices.
2017-06-23 06:16:45 +00:00
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
```
Only the command `logbook.compute` requires a running task server (celery) at the moment.
2015-11-15 08:26:09 +00:00
### Available tasks
2015-11-15 08:26:09 +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
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).