Move the SQL stuff out of uhd_modes and into modes_kml, keeps things neat

This commit is contained in:
Nick Foster
2012-01-30 18:50:04 -08:00
parent 82ce9feec0
commit 105950c176
2 changed files with 9 additions and 7 deletions

View File

@@ -153,10 +153,9 @@ if __name__ == '__main__':
updates = [] #registry of plugin update functions
if options.kml is not None:
sqlport = air_modes.modes_output_sql(my_position, '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 = air_modes.modes_kml('adsb.db', options.kml, my_position) #create a KML generating thread which reads the database
#we spawn a thread to run every 30 seconds (or whatever) to generate KML
kmlgen = air_modes.modes_kml(options.kml, my_position) #create a KML generating thread
outputs.append(kmlgen.output)
if options.sbs1 is True:
sbs1port = air_modes.modes_output_sbs1(my_position)

View File

@@ -21,14 +21,17 @@
import sqlite3
import string, math, threading, time
from air_modes.modes_sql import modes_output_sql
class modes_kml(threading.Thread):
def __init__(self, dbfile, filename, localpos, timeout=5):
def __init__(self, filename, localpos, timeout=5):
threading.Thread.__init__(self)
self._filename = filename
self._dbfile = dbfile
self.my_coords = localpos
self._timeout = timeout
self._dbname = 'adsb.db'
self._sqlobj = modes_output_sql(self.my_coords, self._dbname)
self.done = False
self.setDaemon(1)
self.start()
@@ -41,7 +44,7 @@ class modes_kml(threading.Thread):
self.done = True
def output(self):
self._db = sqlite3.connect(self._dbfile)
self._db = sqlite3.connect(self._dbname)
kmlstr = self.genkml()
if kmlstr is not None:
f = open(self._filename, 'w')