def inner_sig_handler(signum, frame): print 'Cntrl-C pressed' # # Dump flights table as cvs file # print "Dump flights table" dump_flights() # # Dump tracks from flights table as .gpx # print "Dump tracks" dump_tracks2(cursor, db) # # Delete entries from daily flight logging tables # delete_table("flight_log") delete_table("flight_log2") delete_table("flight_log_final") delete_table("flight_group") delete_table("flights") delete_table("track") delete_table("trackFinal") delete_table("flarm_db") db.commit() print "Cntrl-C, exit" exit()
# Set datetime to current time location.date = ephem.Date(datetime.datetime.now()) print "Ephem date is: ", location.date s = ephem.Sun() s.compute(location) twilight = -6 * ephem.degree # Defn of Twilight is: Sun is 6, 12, 18 degrees below horizon (civil, nautical, astronomical) if s.alt > twilight: print "Is it light at Location? Yes", location, " Ephem date is: ", ephem.Date(location.date), " Next sunset at: ", location.next_setting(ephem.Sun()) else: print "Is it light at Location? No", location, " Ephem date is: ", ephem.Date(location.date), " Next sunrise at: ", location.next_rising(ephem.Sun()) process_log(cursor,db) # # Dump flights table as cvs file # print "Dump flights table" dump_flights() # # Delete entries from daily flight logging tables # try: cursor.execute('''DELETE FROM flight_log''') print "Delete flight_log table ok" except: print "Delete flight_log table failed or no records in tables" try: cursor.execute('''DELETE FROM flight_log2''') print "Delete flight_log2 table ok" except: print "Delete flight_log2 table failed or no records in tables" try: cursor.execute('''DELETE FROM flight_log_final''')
s.compute(location) twilight = -6 * ephem.degree # Defn of Twilight is: Sun is 6, 12, 18 degrees below horizon (civil, nautical, astronomical) if s.alt > twilight: print "Is it light at Location? Yes", location, " Ephem date is: ", ephem.Date( location.date), " Next sunset at: ", location.next_setting( ephem.Sun()) else: print "Is it light at Location? No", location, " Ephem date is: ", ephem.Date( location.date), " Next sunrise at: ", location.next_rising( ephem.Sun()) process_log(cursor, db) # # Dump flights table as cvs file # print "Dump flights table" dump_flights() # # Delete entries from daily flight logging tables # try: cursor.execute('''DELETE FROM flight_log''') print "Delete flight_log table ok" except: print "Delete flight_log table failed or no records in tables" try: cursor.execute('''DELETE FROM flight_log2''') print "Delete flight_log2 table ok" except: print "Delete flight_log2 table failed or no records in tables" try: cursor.execute('''DELETE FROM flight_log_final''')