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:
Nick Foster 2010-10-23 16:51:09 -07:00
parent 839596a4b2
commit 0d4194ef84
4 changed files with 13 additions and 11 deletions

View File

@ -1,3 +1,4 @@
#!/usr/bin/env python
#
# Copyright 2010 Nick Foster
#
@ -19,9 +20,6 @@
# Boston, MA 02110-1301, USA.
#
#!/usr/bin/env python
from modes_parse import *
from cpr import *
import sys

View File

@ -29,8 +29,6 @@ class modes_output_print(modes_parse.modes_parse):
def parse(self, message):
[msgtype, shortdata, longdata, parity, ecc, reference] = message.split()
if reference is None: reference = 0
shortdata = long(shortdata, 16)
longdata = long(longdata, 16)
parity = long(parity, 16)
@ -54,7 +52,13 @@ class modes_output_print(modes_parse.modes_parse):
else:
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

View File

@ -25,9 +25,9 @@ import modes_parse
import sqlite3
class modes_output_sql(modes_parse.modes_parse):
def __init__(self):
def __init__(self, filename):
#create the database
self.db = sqlite3.connect('adsb.db')
self.db = sqlite3.connect(filename)
#now execute a schema to create the tables you need
c = self.db.cursor()
query = """CREATE TABLE IF NOT EXISTS "positions" (

View File

@ -149,7 +149,7 @@ if __name__ == '__main__':
updates = [] #registry of plugin update functions
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)
#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