Added new flights.py submitted by @adamkaplan.

pull/222/head
Joe Prochazka 2016-09-09 11:28:11 -04:00
rodzic 01271a7f7a
commit 7fa44bd331
3 zmienionych plików z 36 dodań i 12 usunięć

Wyświetl plik

@ -276,6 +276,9 @@ if [ $ADVANCED = TRUE ]; then
fi
;;
esac
# Flight logging prerequisites.
CheckPackage python-pip
fi
# Reload Lighttpd after installing the prerequisite packages.

Wyświetl plik

@ -39,6 +39,16 @@ PORTALBUILDDIRECTORY="$BUILDDIRECTORY/portal"
DATABASEENGINE=`grep 'db_driver' $LIGHTTPDDOCUMENTROOT/classes/settings.class.php | tail -n1 | cut -d\' -f2`
PYTHONPATH=`which python`
## SETUP PYTHON
# Install the Python inotify module using pip.
echo ""
echo -e "\e[95m Setting up Python...\e[97m"
echo ""
echo -e "\e[94m Installing the Python inotify module...\e[97m"
echo ""
sudo pip install inotify
## SETUP FLIGHT LOGGING
echo ""

Wyświetl plik

@ -36,7 +36,9 @@
# 3) Update the last time the flight was seen.
import datetime
import inotify.adapters
import json
import re
import time
import os
#import urllib2
@ -178,10 +180,19 @@ class FlightsProcessor(object):
if __name__ == "__main__":
processor = FlightsProcessor(config)
mutability_dir = '/run/dump1090-mutability/'
i = inotify.adapters.Inotify()
i.add_watch(mutability_dir)
# Main run loop
while True:
for event in i.event_gen():
if event is not None:
(header, type_names, watch_path, filename) = event
if 'IN_MOVED_TO' in type_names and re.match('^history_\d+\.json$', filename):
# Read dump1090-mutability's aircraft.json.
with open('/run/dump1090-mutability/aircraft.json') as data_file:
#with open('/run/dump1090-mutability/aircraft.json') as data_file:
with open(mutability_dir + filename) as data_file:
data = json.load(data_file)
# For testing using a remote JSON feed.
#response = urllib2.urlopen('http://192.168.254.2/dump1090/data/aircraft.json')
@ -190,4 +201,4 @@ if __name__ == "__main__":
processor.processAircraftList(data["aircraft"])
log("Last Run: " + datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S"))
time.sleep(15)