pull/26/head
Fabian P. Schmidt 2016-01-06 00:23:45 +01:00
rodzic d5dc94903d
commit 4baeb83516
7 zmienionych plików z 50 dodań i 60 usunięć

Wyświetl plik

@ -40,57 +40,49 @@ def show(airport_name, latitude, longitude, altitude):
# make a query with current, previous and next "takeoff_landing" event, so we can find complete flights
sq = session.query(
TakeoffLanding.address,
func.lag(TakeoffLanding.address) \
func.lag(TakeoffLanding.address)
.over(
order_by=and_(func.date(TakeoffLanding.timestamp),
TakeoffLanding.address,
TakeoffLanding.timestamp)) \
TakeoffLanding.timestamp))
.label('address_prev'),
func.lead(TakeoffLanding.address) \
.over(
order_by=and_(func.date(TakeoffLanding.timestamp),
TakeoffLanding.address,
TakeoffLanding.timestamp)) \
.label('address_next'),
TakeoffLanding.timestamp,
func.lag(
TakeoffLanding.timestamp) \
.over(
order_by=and_(func.date(TakeoffLanding.timestamp),
TakeoffLanding.address,
TakeoffLanding.timestamp)) \
.label('timestamp_prev'),
func.lead(
TakeoffLanding.timestamp) \
.over(order_by=and_(func.date(TakeoffLanding.timestamp),
TakeoffLanding.address,
TakeoffLanding.timestamp)) \
.label('timestamp_next'),
TakeoffLanding.track,
func.lag(
TakeoffLanding.track) \
.over(order_by=and_(func.date(TakeoffLanding.timestamp),
TakeoffLanding.address,
TakeoffLanding.timestamp)) \
.label('track_prev'),
func.lead(
TakeoffLanding.track) \
.over(order_by=and_(func.date(TakeoffLanding.timestamp),
TakeoffLanding.address,
TakeoffLanding.timestamp)) \
.label('track_next'),
TakeoffLanding.is_takeoff,
func.lag(
TakeoffLanding.is_takeoff) \
.over(order_by=and_(func.date(TakeoffLanding.timestamp),
TakeoffLanding.address,
TakeoffLanding.timestamp)) \
.label('is_takeoff_prev'),
func.lead(
TakeoffLanding.is_takeoff) \
func.lead(TakeoffLanding.address)
.over(order_by=and_(func.date(TakeoffLanding.timestamp),
TakeoffLanding.address,
TakeoffLanding.timestamp))
.label('address_next'),
TakeoffLanding.timestamp,
func.lag(TakeoffLanding.timestamp)
.over(order_by=and_(func.date(TakeoffLanding.timestamp),
TakeoffLanding.address,
TakeoffLanding.timestamp)) \
TakeoffLanding.timestamp))
.label('timestamp_prev'),
func.lead(TakeoffLanding.timestamp)
.over(order_by=and_(func.date(TakeoffLanding.timestamp),
TakeoffLanding.address,
TakeoffLanding.timestamp))
.label('timestamp_next'),
TakeoffLanding.track,
func.lag(TakeoffLanding.track)
.over(order_by=and_(func.date(TakeoffLanding.timestamp),
TakeoffLanding.address,
TakeoffLanding.timestamp))
.label('track_prev'),
func.lead(TakeoffLanding.track)
.over(order_by=and_(func.date(TakeoffLanding.timestamp),
TakeoffLanding.address,
TakeoffLanding.timestamp))
.label('track_next'),
TakeoffLanding.is_takeoff,
func.lag(TakeoffLanding.is_takeoff)
.over(order_by=and_(func.date(TakeoffLanding.timestamp),
TakeoffLanding.address,
TakeoffLanding.timestamp))
.label('is_takeoff_prev'),
func.lead(TakeoffLanding.is_takeoff)
.over(order_by=and_(func.date(TakeoffLanding.timestamp),
TakeoffLanding.address,
TakeoffLanding.timestamp))
.label('is_takeoff_next')) \
.filter(and_(between(TakeoffLanding.latitude, latmin, latmax),
between(TakeoffLanding.longitude, lonmin, lonmax))) \

Wyświetl plik

@ -1,4 +1,4 @@
from ogn.commands.dbutils import engine, session
from ogn.commands.dbutils import session
from ogn.model import AddressOrigin, Device
from sqlalchemy import func, and_, true, false

Wyświetl plik

@ -38,7 +38,7 @@ class ognGateway:
# close everything
self.sock.shutdown(0)
self.sock.close()
except OSError as e:
except OSError:
self.logger.error('Socket close error', exc_info=True)
def run(self, callback, autoreconnect=False):

Wyświetl plik

@ -9,9 +9,9 @@ from geopy.geocoders import Nominatim
DDB_URL = "http://ddb.glidernet.org/download"
address_prefixes = {'F':'FLR',
'O':'OGN',
'I':'ICA'}
address_prefixes = {'F': 'FLR',
'O': 'OGN',
'I': 'ICA'}
def get_ddb(csvfile=None):
@ -45,11 +45,11 @@ def get_ddb(csvfile=None):
def get_trackable(ddb):
l = []
for i in ddb:
if i.tracked and i.address_type in address_prefixes:
l.append('{}{}'.format(address_prefixes[i.address_type], i.address))
return l
l = []
for i in ddb:
if i.tracked and i.address_type in address_prefixes:
l.append('{}{}'.format(address_prefixes[i.address_type], i.address))
return l
def get_country_code(latitude, longitude):

Wyświetl plik

@ -25,5 +25,3 @@ class GatewayTest(unittest.TestCase):
self.gw.disconnect()
self.gw.sock.shutdown.assert_called_once_with(0)
self.gw.sock.close.assert_called_once_with()

Wyświetl plik

@ -19,7 +19,7 @@ class TestStringMethods(unittest.TestCase):
self.assertFalse(aircraft_beacon.stealth)
self.assertEqual(aircraft_beacon.address, "DDA5BA")
self.assertAlmostEqual(aircraft_beacon.climb_rate*ms2fpm, -454, 2)
self.assertAlmostEqual(aircraft_beacon.climb_rate * ms2fpm, -454, 2)
self.assertEqual(aircraft_beacon.turn_rate, -1.1)
self.assertEqual(aircraft_beacon.signal_strength, 8.8)
self.assertEqual(aircraft_beacon.error_count, 0)

Wyświetl plik

@ -26,8 +26,8 @@ class TestStringMethods(unittest.TestCase):
self.assertAlmostEqual(beacon.longitude, dmsToDeg(6.0003), 5)
self.assertEqual(beacon.symbolcode, '\'')
self.assertEqual(beacon.track, 342)
self.assertEqual(beacon.ground_speed, 49*kts2kmh)
self.assertAlmostEqual(beacon.altitude*m2feet, 5524, 5)
self.assertEqual(beacon.ground_speed, 49 * kts2kmh)
self.assertAlmostEqual(beacon.altitude * m2feet, 5524, 5)
self.assertEqual(beacon.comment, "this is a comment")