diff --git a/python/modes_kml.py b/python/modes_kml.py index 44783b7..6ea9393 100644 --- a/python/modes_kml.py +++ b/python/modes_kml.py @@ -27,8 +27,7 @@ class modes_kml(threading.Thread, modes_output_sql): def __init__(self, filename, localpos, timeout=5): threading.Thread.__init__(self) self._dbname = 'adsb.db' - modes_output_sql.__init__(localpos, self._dbname) #write to the db - self._db = sqlite3.connect(self._dbname) #read from the db + modes_output_sql.__init__(self, localpos, self._dbname) #write to the db self._filename = filename self.my_coords = localpos self._timeout = timeout @@ -38,6 +37,7 @@ class modes_kml(threading.Thread, modes_output_sql): self.start() def run(self): + self._db = sqlite3.connect(self._dbname) #read from the db while self.done is False: self.writekml() time.sleep(self._timeout) @@ -83,11 +83,12 @@ class modes_kml(threading.Thread, modes_output_sql): retstr="""\n\n\n\t\n\t\n\t""" if self.my_coords is not None: - retstr += """\t\n\t\tRange rings\n\t\t0""" + retstr += """\n\t\n\t\tRange rings\n\t\t0""" for rng in [100, 200, 300]: retstr += """\n\t\t\n\t\t\t%inm\n\t\t\t#rangering\n\t\t\t\n\t\t\t\t%s\n\t\t\t\n\t\t""" % (rng, self.draw_circle(self.my_coords, rng),) + retstr += """\t\n""" - retstr += """\t\n\t\n\t\tAircraft locations\n\t\t0""" + retstr += """\t\n\t\tAircraft locations\n\t\t0""" #read the database and add KML q = "select distinct icao from positions where seen > datetime('now', '-5 minute')" @@ -115,7 +116,7 @@ class modes_kml(threading.Thread, modes_output_sql): trackstr = "" for pos in track: - trackstr += " %f,%f,%f" % (pos[4], pos[3], pos[2]*0.3048) + trackstr += " %f, %f, %f" % (pos[4], pos[3], pos[2]*0.3048) trackstr = string.lstrip(trackstr) else: diff --git a/python/modes_sql.py b/python/modes_sql.py index 36ef33d..bafde26 100644 --- a/python/modes_sql.py +++ b/python/modes_sql.py @@ -57,7 +57,7 @@ class modes_output_sql(modes_parse.modes_parse): def __del__(self): self.db.close() - def insert(self, message): + def output(self, message): query = self.make_insert_query(message) if query is not None: c = self.db.cursor()