01234567890123456789012345678901234567890123456789012345678901234567890123456789
537053715372537353745375537653775378537953805381538253835384538553865387538853895390 5391 53925393539453955396539753985399540054015402540354045405540654075408540954105411 | <----SKIPPED LINES----> 'Flight (%s; %s) is overwriting the prior ' 'recorded flight (%s; %s) due to updated identifiers' % ( flight.get('flight_number'), flight.get('squawk'), last_flight.get('flight_number'), last_flight.get('squawk'))) flights[-1] = flight # 2) replace the last pickled record # # There is potential complication in that the last flight and the new flight # crossed into a new day, and we are using date segmentation so that the last # flight exists in yesterday's file max_days = 1 if not SIMULATION and DisplayTime(flight, '%x') != DisplayTime(last_flight, '%x'): max_days = 2 message += ( '; in repickling, we crossed days, so pickled flights that might otherwise' ' be in %s file are now all located in %s file' % ( DisplayTime(last_flight, '%x'), DisplayTime(flight, '%x'))) Log(message) saved_flights = UnpickleObjectFromFile(PICKLE_FLIGHTS, not SIMULATION, max_days=max_days) saved_flights[-1] = flight for f in saved_flights: PickleObjectToFile(f, PICKLE_FLIGHTS, not SIMULATION) return False def HeartbeatRestart(): if SIMULATION: return 0 UpdateDashboard(True) # Indicates that this wasn't running a moment before, ... UpdateDashboard(False) # ... and now it is running! return time.time() def Heartbeat(last_heartbeat_time): if SIMULATION: return last_heartbeat_time now = time.time() if now - last_heartbeat_time > HEARTBEAT_SECONDS: UpdateDashboard(False) last_heartbeat_time = now <----SKIPPED LINES----> |
01234567890123456789012345678901234567890123456789012345678901234567890123456789
537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420 | <----SKIPPED LINES----> 'Flight (%s; %s) is overwriting the prior ' 'recorded flight (%s; %s) due to updated identifiers' % ( flight.get('flight_number'), flight.get('squawk'), last_flight.get('flight_number'), last_flight.get('squawk'))) flights[-1] = flight # 2) replace the last pickled record # # There is potential complication in that the last flight and the new flight # crossed into a new day, and we are using date segmentation so that the last # flight exists in yesterday's file max_days = 1 if not SIMULATION and DisplayTime(flight, '%x') != DisplayTime(last_flight, '%x'): max_days = 2 message += ( '; in repickling, we crossed days, so pickled flights that might otherwise' ' be in %s file are now all located in %s file' % ( DisplayTime(last_flight, '%x'), DisplayTime(flight, '%x'))) Log(message) args = (PICKLE_FLIGHTS, not SIMULATION, max_days) saved_flights = UnpickleObjectFromFile(*args) files_to_overwrite = UnpickleObjectFromFile(*args, filenames=True) if saved_flights: saved_flights[-1] = flight else: saved_flights = [flight] for file in files_to_overwrite: os.remove(file) for f in saved_flights: PickleObjectToFile(f, PICKLE_FLIGHTS, not SIMULATION) return False def HeartbeatRestart(): if SIMULATION: return 0 UpdateDashboard(True) # Indicates that this wasn't running a moment before, ... UpdateDashboard(False) # ... and now it is running! return time.time() def Heartbeat(last_heartbeat_time): if SIMULATION: return last_heartbeat_time now = time.time() if now - last_heartbeat_time > HEARTBEAT_SECONDS: UpdateDashboard(False) last_heartbeat_time = now <----SKIPPED LINES----> |