A database backend for the Open Glider Network
 
 
 
 
 
 
Go to file
Konstantin Gründger 6fffa09e20 Repair db scheme for ognrange 2019-01-07 23:51:40 +01:00
alembic Wrong table... 2016-11-01 10:42:23 +01:00
config Improvements and fixes 2018-10-21 17:34:03 +02:00
ogn Repair db scheme for ognrange 2019-01-07 23:51:40 +01:00
tests Repair db scheme for ognrange 2019-01-07 23:51:40 +01:00
.gitignore gitignore: Add celerybeat-schedule 2016-02-17 18:26:00 +01:00
.travis.yml Update python versions 2019-01-04 16:43:41 +01:00
CHANGELOG.md Preparation for 0.3.0 2016-10-22 09:22:40 +02:00
CONTRIBUTORS Appended contributors list 2016-09-28 11:31:40 +02:00
LICENSE Create LICENSE 2015-11-14 22:47:25 +01:00
MANIFEST.in Add MANIFEST.in to include README,LICENSE & tests 2016-01-12 17:24:28 +01:00
README.md Repair db scheme for ognrange 2019-01-07 23:51:40 +01:00
Vagrantfile Add Vagrantfile 2016-09-23 20:27:00 +02:00
alembic.ini alembic: Load configuration from ogn config 2016-01-31 02:20:00 +01:00
manage.py Add common CLI manage.py. 2015-11-15 09:59:48 +01:00
requirements.txt Add setup.py to create a package 2016-01-12 13:56:18 +01:00
setup.cfg Refactoring 2016-07-01 07:19:31 +02:00
setup.py Replace psycopg2 with psycopg2-binary 2019-01-03 18:58:47 +01:00

README.md

ogn-python

Build Status Coverage Status

A database backend for the Open Glider Network. The ogn-python module saves all received beacons into a database with SQLAlchemy. It connects to the OGN aprs servers with python-ogn-client. It requires PostgreSQL and PostGIS. For best performance you should use TimescaleDB, which is based on PostgreSQL.

Examples

Installation and Setup

  1. Checkout the repository

    git clone https://github.com/glidernet/ogn-python.git
    
  2. Install python requirements

    pip install -r requirements.txt
    
  3. Install PostgreSQL with PostGIS Extension. Create a database (use "ogn" as default, otherwise you have to modify the configuration, see below)

  4. Optional: Install redis for asynchronous tasks (like takeoff/landing-detection)

    apt-get install redis-server
    
  5. Create database

    ./manage.py db.init
    
  6. Optional: Prepare tables for TimescaleDB

    ./manage.py db.init_timescaledb
    

There is also a Vagrant 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

Running the aprs client and task server

To schedule tasks like takeoff/landing-detection (logbook.compute), Celery with Redis is used. The following scripts run in the foreground and should be deamonized (eg. use supervisord).

  • Start the aprs client

    ./manage.py gateway.run
    
  • Start a task server (make sure redis is up and running)

    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) and set the environment variable OGN_CONFIG_MODULE accordingly.

touch myconfig.py
export OGN_CONFIG_MODULE="myconfig"
./manage.py gateway.run

manage.py - CLI options

usage: manage [<namespace>.]<command> [<args>]

positional arguments:
  command     the command to run

optional arguments:
  -h, --help  show this help message and exit

available commands:
  
  [bulkimport]
    create_flights2d       Create complete flight traces from logfile tables.
    create_gaps2d          Create 'gaps' from logfile tables.
    file_export            Export separate logfile tables to csv files. They can be used for fast bulk import with sql COPY command.
    file_import            Import APRS logfiles into separate logfile tables.
    transfer               Transfer beacons from separate logfile tables to beacon table.
    update                 Update beacons (add foreign keys, compute distance, bearing, ags, etc.) in separate logfile tables.
  
  [db]
    drop                   Drop all tables.
    import_airports        Import airports from a ".cup" file
    import_ddb             Import registered devices from the DDB.
    import_file            Import registered devices from a local file.
    import_flarmnet        Import registered devices from a local file.
    init                   Initialize the database.
    init_timescaledb       Initialize TimescaleDB features.
    update_country_codes   Update country codes of all receivers.
    upgrade                Upgrade database to the latest version.
  
  [flights]
    flights2d              Compute flights.
  
  [gateway]
    run                    Run the aprs client.
  
  [igcexport]
    write                  Export igc file for <address> at <date>.
  
  [logbook]
    compute_logbook        Compute logbook.
    compute_takeoff_landingCompute takeoffs and landings.
    show                   Show a logbook for <airport_name>.
  
  [stats]
    create                 Create DeviceStats, ReceiverStats and RelationStats.
    create_ognrange        Create stats for Melissa's ognrange.
    update_devices         Update devices with data from stats.
    update_receivers       Update receivers with data from stats.

Only the command logbook.compute requires a running task server (celery) at the moment.

Available tasks

  • ogn.collect.database.import_ddb - Import registered devices from the DDB.
  • ogn.collect.database.import_file - Import registered devices from a local file.
  • ogn.collect.database.update_country_code - Update country code in receivers table if None.
  • ogn.collect.database.update_devices - Add/update entries in devices table and update foreign keys in aircraft beacons.
  • ogn.collect.database.update_receivers - Add/update_receivers entries in receiver table and update receivers foreign keys and distance in aircraft beacons and update foreign keys in receiver beacons.
  • ogn.collect.logbook.update_logbook - Add/update logbook entries.
  • ogn.collect.logbook.update_max_altitude - Add max altitudes in logbook when flight is complete (takeoff and landing).
  • ogn.collect.stats.update_device_stats - Add/update entries in device stats table.
  • ogn.collect.stats.update_receiver_stats - Add/update entries in receiver stats table.
  • ogn.collect.takeoff_landing.update_takeoff_landing - Compute takeoffs and landings.

If the task server is up and running, tasks could be started manually.

python3
>>>from ogn.collect.database import import_ddb
>>>import_ddb.delay()

License

Licensed under the AGPLv3.