Don't mess with frame if it can't be parsed.
This commit is contained in:
		@@ -90,35 +90,36 @@ def main():
 | 
				
			|||||||
        for frame in ki.read(min_frames=1):
 | 
					        for frame in ki.read(min_frames=1):
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                a = aprslib.parse(str(frame))
 | 
					                a = aprslib.parse(str(frame))
 | 
				
			||||||
            except:
 | 
					                a['station_call'] = config['Settings']['station_call']
 | 
				
			||||||
                a = dict()
 | 
					                a['station_lat'] = config['Settings']['station_lat']
 | 
				
			||||||
            a['station_call'] = config['Settings']['station_call']
 | 
					                a['station_lon'] = config['Settings']['station_lon']
 | 
				
			||||||
            a['station_lat'] = config['Settings']['station_lat']
 | 
					                print(a)
 | 
				
			||||||
            a['station_lon'] = config['Settings']['station_lon']
 | 
					                # Make this a string and deal with it later (probably a mistake)
 | 
				
			||||||
            print(a)
 | 
					                a['path'] = str(a['path'])
 | 
				
			||||||
            # Make this a string and deal with it later (probably a mistake)
 | 
					                # Store true/false as 1/0
 | 
				
			||||||
            a['path'] = str(a['path'])
 | 
					                if 'alive' in a:
 | 
				
			||||||
            # Store true/false as 1/0
 | 
					                    if a['alive'] == True:
 | 
				
			||||||
            if 'alive' in a:
 | 
					                        a['alive'] = 1
 | 
				
			||||||
                if a['alive'] == True:
 | 
					                    else:
 | 
				
			||||||
                    a['alive'] = 1
 | 
					                        a['alive'] = 0
 | 
				
			||||||
                else:
 | 
					                # Build an INSERT statement based on the fields we have from the frame
 | 
				
			||||||
                    a['alive'] = 0
 | 
					                attrib_names = ', '.join('"%s"' % w for w in a.keys())
 | 
				
			||||||
            # Build an INSERT statement based on the fields we have from the frame
 | 
					                attrib_values = ", ".join("?" * len(a.keys()))
 | 
				
			||||||
            attrib_names = ', '.join('"%s"' % w for w in a.keys())
 | 
					                sql = "INSERT INTO frames ("+attrib_names+") VALUES ("+attrib_values+")"
 | 
				
			||||||
            attrib_values = ", ".join("?" * len(a.keys()))
 | 
					                try:
 | 
				
			||||||
            sql = "INSERT INTO frames ("+attrib_names+") VALUES ("+attrib_values+")"
 | 
					                    # Insert data
 | 
				
			||||||
            try:
 | 
					                    conn.execute(sql, list(a.values()))
 | 
				
			||||||
                # Insert data
 | 
					                    conn.commit()
 | 
				
			||||||
                conn.execute(sql, list(a.values()))
 | 
					 | 
				
			||||||
                conn.commit()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                # TODO remove packets that are older ('created') than a limit set in config.ini
 | 
					                    # TODO remove packets that are older ('created') than a limit set in config.ini
 | 
				
			||||||
                # "5 minutes" also works
 | 
					                    # "5 minutes" also works
 | 
				
			||||||
                conn.execute("DELETE FROM frames WHERE created < DATETIME('now', '"+config['Settings']['keep_time']+"')")
 | 
					                    conn.execute("DELETE FROM frames WHERE created < DATETIME('now', '"+config['Settings']['keep_time']+"')")
 | 
				
			||||||
                conn.commit()
 | 
					                    conn.commit()
 | 
				
			||||||
 | 
					                except:
 | 
				
			||||||
 | 
					                    print("Error with SQLite!")
 | 
				
			||||||
            except:
 | 
					            except:
 | 
				
			||||||
                print("Error with SQLite!")
 | 
					                print("Frame could not be parsed.")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        conn.close()
 | 
					        conn.close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user