Fixed some indenting so outputs are only called when there's something to output. Hopefully also fixed that pesky NoneType error.
This commit is contained in:
parent
839596a4b2
commit
0d4194ef84
@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
#
|
#
|
||||||
# Copyright 2010 Nick Foster
|
# Copyright 2010 Nick Foster
|
||||||
#
|
#
|
||||||
@ -19,9 +20,6 @@
|
|||||||
# Boston, MA 02110-1301, USA.
|
# Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
from modes_parse import *
|
from modes_parse import *
|
||||||
from cpr import *
|
from cpr import *
|
||||||
import sys
|
import sys
|
||||||
|
@ -29,8 +29,6 @@ class modes_output_print(modes_parse.modes_parse):
|
|||||||
def parse(self, message):
|
def parse(self, message):
|
||||||
[msgtype, shortdata, longdata, parity, ecc, reference] = message.split()
|
[msgtype, shortdata, longdata, parity, ecc, reference] = message.split()
|
||||||
|
|
||||||
if reference is None: reference = 0
|
|
||||||
|
|
||||||
shortdata = long(shortdata, 16)
|
shortdata = long(shortdata, 16)
|
||||||
longdata = long(longdata, 16)
|
longdata = long(longdata, 16)
|
||||||
parity = long(parity, 16)
|
parity = long(parity, 16)
|
||||||
@ -54,7 +52,13 @@ class modes_output_print(modes_parse.modes_parse):
|
|||||||
else:
|
else:
|
||||||
output = "No handler for message type " + str(msgtype) + " from " + str(ecc)
|
output = "No handler for message type " + str(msgtype) + " from " + str(ecc)
|
||||||
|
|
||||||
output = "(%.0f) " % (10.0*math.log10(float(reference))) + output
|
|
||||||
|
if reference == 0:
|
||||||
|
refdb = 0
|
||||||
|
else:
|
||||||
|
refdb = 10.0*math.log10(reference)
|
||||||
|
|
||||||
|
output = "(%.0f) " % (refdb) + output
|
||||||
|
|
||||||
print output
|
print output
|
||||||
|
|
||||||
|
@ -25,9 +25,9 @@ import modes_parse
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
|
|
||||||
class modes_output_sql(modes_parse.modes_parse):
|
class modes_output_sql(modes_parse.modes_parse):
|
||||||
def __init__(self):
|
def __init__(self, filename):
|
||||||
#create the database
|
#create the database
|
||||||
self.db = sqlite3.connect('adsb.db')
|
self.db = sqlite3.connect(filename)
|
||||||
#now execute a schema to create the tables you need
|
#now execute a schema to create the tables you need
|
||||||
c = self.db.cursor()
|
c = self.db.cursor()
|
||||||
query = """CREATE TABLE IF NOT EXISTS "positions" (
|
query = """CREATE TABLE IF NOT EXISTS "positions" (
|
||||||
|
@ -149,7 +149,7 @@ if __name__ == '__main__':
|
|||||||
updates = [] #registry of plugin update functions
|
updates = [] #registry of plugin update functions
|
||||||
|
|
||||||
if options.kml is not None:
|
if options.kml is not None:
|
||||||
sqlport = modes_output_sql() #create a SQL parser to push stuff into SQLite
|
sqlport = modes_output_sql('adsb.db') #create a SQL parser to push stuff into SQLite
|
||||||
outputs.append(sqlport.insert)
|
outputs.append(sqlport.insert)
|
||||||
#also we spawn a thread to run every 30 seconds (or whatever) to generate KML
|
#also we spawn a thread to run every 30 seconds (or whatever) to generate KML
|
||||||
kmlgen = modes_kml('adsb.db', options.kml) #create a KML generating thread which reads the database
|
kmlgen = modes_kml('adsb.db', options.kml) #create a KML generating thread which reads the database
|
||||||
|
Loading…
Reference in New Issue
Block a user