Compare commits
No commits in common. "4642f45adced7b3c19ce9fd5d701751949a1c17f" and "4439ae680ea20e467cfdc78c62a0d5c0e1c878bb" have entirely different histories.
4642f45adc
...
4439ae680e
@ -22,7 +22,6 @@ db_frames_fields = ("id",
|
|||||||
"mtype",
|
"mtype",
|
||||||
"object_format",
|
"object_format",
|
||||||
"object_name",
|
"object_name",
|
||||||
"party",
|
|
||||||
"path",
|
"path",
|
||||||
"phg",
|
"phg",
|
||||||
"phg_dir",
|
"phg_dir",
|
||||||
@ -33,7 +32,6 @@ db_frames_fields = ("id",
|
|||||||
"posambiguity",
|
"posambiguity",
|
||||||
"raw",
|
"raw",
|
||||||
"raw_timestamp",
|
"raw_timestamp",
|
||||||
"rng",
|
|
||||||
"speed",
|
"speed",
|
||||||
"station_call",
|
"station_call",
|
||||||
"station_lat",
|
"station_lat",
|
||||||
|
@ -73,21 +73,11 @@ def main():
|
|||||||
a['station_lat'] = config['Settings']['station_lat']
|
a['station_lat'] = config['Settings']['station_lat']
|
||||||
a['station_lon'] = config['Settings']['station_lon']
|
a['station_lon'] = config['Settings']['station_lon']
|
||||||
a['created_unix'] = int(time.time())
|
a['created_unix'] = int(time.time())
|
||||||
a['party'] = 1
|
|
||||||
|
|
||||||
# Make this a string and deal with it later (probably a mistake)
|
# Make this a string and deal with it later (probably a mistake)
|
||||||
a['path'] = str(a['path'])
|
a['path'] = str(a['path'])
|
||||||
# Process 3rd-party data
|
|
||||||
if 'subpacket' in a:
|
if 'subpacket' in a:
|
||||||
b = a['subpacket'] # make a copy
|
a['subpacket'] = str(a['subpacket'])
|
||||||
a['subpacket'] = str(a['subpacket']) # turn the original to a string
|
|
||||||
b['party'] = 3
|
|
||||||
b['path'] = str(b['path'])
|
|
||||||
b['header_raw'] = a['raw'].split("}", 1)[0] # just the first part
|
|
||||||
b['station_call'] = config['Settings']['station_call']
|
|
||||||
b['station_lat'] = config['Settings']['station_lat']
|
|
||||||
b['station_lon'] = config['Settings']['station_lon']
|
|
||||||
b['created_unix'] = int(time.time())
|
|
||||||
#logging.debug(a['path'])
|
#logging.debug(a['path'])
|
||||||
# Store true/false as 1/0
|
# Store true/false as 1/0
|
||||||
if 'alive' in a:
|
if 'alive' in a:
|
||||||
@ -100,21 +90,12 @@ def main():
|
|||||||
attrib_values = ", ".join("?" * len(a.keys()))
|
attrib_values = ", ".join("?" * len(a.keys()))
|
||||||
logging.debug(attrib_names)
|
logging.debug(attrib_names)
|
||||||
logging.debug(a.values())
|
logging.debug(a.values())
|
||||||
if 'subpacket' in a:
|
|
||||||
# 3rd-party
|
logging.debug("Inserting into database")
|
||||||
b_attrib_names = ', '.join('"%s"' % w for w in b.keys())
|
|
||||||
b_attrib_values = ", ".join("?" * len(b.keys()))
|
|
||||||
logging.debug(b_attrib_names)
|
|
||||||
logging.debug(b.values())
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
logging.debug("Inserting into database")
|
|
||||||
# Insert data
|
# Insert data
|
||||||
sql = "INSERT INTO frames ("+attrib_names+") VALUES ("+attrib_values+")"
|
sql = "INSERT INTO frames ("+attrib_names+") VALUES ("+attrib_values+")"
|
||||||
conn.execute(sql, list(a.values()))
|
conn.execute(sql, list(a.values()))
|
||||||
if 'subpacket' in a:
|
|
||||||
b_sql = "INSERT INTO frames ("+b_attrib_names+") VALUES ("+b_attrib_values+")"
|
|
||||||
conn.execute(b_sql, list(b.values()))
|
|
||||||
logging.debug("Frames table updated")
|
logging.debug("Frames table updated")
|
||||||
# TODO update stations table here
|
# TODO update stations table here
|
||||||
# Original intent was to include the id from the frames table,
|
# Original intent was to include the id from the frames table,
|
||||||
@ -132,15 +113,6 @@ def main():
|
|||||||
last_heard_unix = excluded.last_heard_unix;"
|
last_heard_unix = excluded.last_heard_unix;"
|
||||||
# Insert/update data
|
# Insert/update data
|
||||||
conn.execute(query3)
|
conn.execute(query3)
|
||||||
if 'subpacket' in a:
|
|
||||||
b_station_update = "'"+b['from'] +"', '"+ str(b['created_unix']) +"', '1'"
|
|
||||||
b_query3 = "INSERT INTO stations ([from], last_heard_unix, count) \
|
|
||||||
VALUES("+b_station_update+") \
|
|
||||||
ON CONFLICT([from]) \
|
|
||||||
DO UPDATE SET count = count + 1,\
|
|
||||||
last_heard_unix = excluded.last_heard_unix;"
|
|
||||||
# Insert/update data
|
|
||||||
conn.execute(b_query3)
|
|
||||||
logging.debug("Station table updated")
|
logging.debug("Station table updated")
|
||||||
conn.commit()
|
conn.commit()
|
||||||
#except:
|
#except:
|
||||||
|
@ -24,7 +24,6 @@ CREATE TABLE frames (
|
|||||||
mtype TEXT,
|
mtype TEXT,
|
||||||
object_format TEXT,
|
object_format TEXT,
|
||||||
object_name TEXT,
|
object_name TEXT,
|
||||||
party INT,
|
|
||||||
path TEXT,
|
path TEXT,
|
||||||
phg REAL,
|
phg REAL,
|
||||||
phg_dir TEXT,
|
phg_dir TEXT,
|
||||||
@ -35,7 +34,6 @@ CREATE TABLE frames (
|
|||||||
posambiguity INT,
|
posambiguity INT,
|
||||||
raw TEXT,
|
raw TEXT,
|
||||||
raw_timestamp TEXT,
|
raw_timestamp TEXT,
|
||||||
rng REAL,
|
|
||||||
speed REAL,
|
speed REAL,
|
||||||
station_call TEXT,
|
station_call TEXT,
|
||||||
station_lat REAL,
|
station_lat REAL,
|
||||||
|
Loading…
Reference in New Issue
Block a user