01234567890123456789012345678901234567890123456789012345678901234567890123456789
15911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631 73387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378 |
<----SKIPPED LINES---->
flight_aware_timestamp = time.time() # "real" timestamp unavailable
elif flight_identifier[0]:
flight_number = flight_identifier[0]
flight_aware_json, error_message, flight_aware_timestamp = (
GetFlightAwareJson(flight_number))
if flight_aware_json:
UpdateStatusLight(GPIO_ERROR_FLIGHT_AWARE_CONNECTION, False)
else:
failure_message = 'No json from Flightaware for flight %s: %s' % (
flight_number, error_message[:500])
Log(failure_message)
UpdateStatusLight(
GPIO_ERROR_FLIGHT_AWARE_CONNECTION, True, failure_message)
flight_details = {}
if flight_aware_json:
flight_details = ParseFlightAwareJson(flight_aware_json)
elif flight_identifier[0]: # if there's a flight number but no json
flight_details, derived_attr_msg = FindAttributesFromSimilarFlights(
flight_identifier[0], flights)
error_message += derived_attr_msg
if not SIMULATION and log_jsons:
PickleObjectToFile((flight_aware_json, now), PICKLE_FA_JSON_FILE, True)
# Augment FlightAware details with radio / radio-derived details
flight_details.update(current_nearby_aircraft[flight_identifier])
# Augment with the past location data; the [1] is because recall that
# persistent_path[key] is actually a 2-tuple, the first element being
# the most recent time seen, and the second element being the actual
# path. But we do not need to keep around the most recent time seen any
# more.
flight_details['persistent_path'] = persistent_path[flight_identifier][1]
return (
persistent_nearby_aircraft,
flight_details,
now,
json_desc_dict,
persistent_path,
<----SKIPPED LINES---->
# Initialize variables for saving in case details not populated by
# later code prior to saving in pickle
time_flight_message_inserted = 0
time_insight_message_inserted = 0
if flight_meets_display_criteria:
personal_message = None # Any personal message displayed now cleared
flight_message = (
FLAG_MSG_FLIGHT, CreateMessageAboutFlight(flight), flight)
# display the next message about this flight now!
next_message_time = time.time()
message_queue.insert(0, flight_message)
time_flight_message_inserted = time.time()
# and delete any queued insight messages about other flights that have
# not yet displayed, since a newer flight has taken precedence
message_queue = DeleteMessageTypes(message_queue, (FLAG_MSG_INSIGHT,))
# Though we also manage the message queue outside this conditional
# as well, because it can take a half second to generate the flight
# insights, this allows this message to start displaying on the
# board immediately, so it's up there when it's most relevant
next_message_time = ManageMessageQueue(
message_queue, next_message_time, configuration, screen_history)
insight_messages = CreateFlightInsights(
flights,
configuration.get('insights'),
insight_message_distribution)
if configuration.get('next_flight', 'off') == 'on':
next_flight_text = FlightInsightNextFlight(flights, configuration)
if next_flight_text:
insight_messages.insert(0, next_flight_text)
insight_messages = [
(FLAG_MSG_INSIGHT, m, flight) for m in insight_messages]
time_insight_message_inserted = time.time()
for insight_message in insight_messages:
message_queue.insert(0, insight_message)
<----SKIPPED LINES---->
|
01234567890123456789012345678901234567890123456789012345678901234567890123456789
15911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631 73387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378 |
<----SKIPPED LINES---->
flight_aware_timestamp = time.time() # "real" timestamp unavailable
elif flight_identifier[0]:
flight_number = flight_identifier[0]
flight_aware_json, error_message, flight_aware_timestamp = (
GetFlightAwareJson(flight_number))
if flight_aware_json:
UpdateStatusLight(GPIO_ERROR_FLIGHT_AWARE_CONNECTION, False)
else:
failure_message = 'No json from Flightaware for flight %s: %s' % (
flight_number, error_message[:500])
Log(failure_message)
UpdateStatusLight(
GPIO_ERROR_FLIGHT_AWARE_CONNECTION, True, failure_message)
flight_details = {}
if flight_aware_json:
flight_details = ParseFlightAwareJson(flight_aware_json)
elif flight_identifier[0]: # if there's a flight number but no json
flight_details, derived_attr_msg = FindAttributesFromSimilarFlights(
flight_identifier[0], flights)
error_message = '%s; %s' % (error_message, derived_attr_msg)
if not SIMULATION and log_jsons:
PickleObjectToFile((flight_aware_json, now), PICKLE_FA_JSON_FILE, True)
# Augment FlightAware details with radio / radio-derived details
flight_details.update(current_nearby_aircraft[flight_identifier])
# Augment with the past location data; the [1] is because recall that
# persistent_path[key] is actually a 2-tuple, the first element being
# the most recent time seen, and the second element being the actual
# path. But we do not need to keep around the most recent time seen any
# more.
flight_details['persistent_path'] = persistent_path[flight_identifier][1]
return (
persistent_nearby_aircraft,
flight_details,
now,
json_desc_dict,
persistent_path,
<----SKIPPED LINES---->
# Initialize variables for saving in case details not populated by
# later code prior to saving in pickle
time_flight_message_inserted = 0
time_insight_message_inserted = 0
if flight_meets_display_criteria:
personal_message = None # Any personal message displayed now cleared
flight_message = (
FLAG_MSG_FLIGHT, CreateMessageAboutFlight(flight), flight)
# display the next message about this flight now!
next_message_time = time.time()
message_queue.insert(0, flight_message)
time_flight_message_inserted = time.time()
# and delete any queued insight messages about other flights that have
# not yet displayed, since a newer flight has taken precedence
message_queue = DeleteMessageTypes(message_queue, (FLAG_MSG_INSIGHT,))
# Though we also manage the message queue outside this conditional
# as well, because it can take a few seconds to generate the flight
# insights, this allows this message to start displaying on the
# board immediately, so it's up there when it's most relevant
next_message_time = ManageMessageQueue(
message_queue, next_message_time, configuration, screen_history)
insight_messages = CreateFlightInsights(
flights,
configuration.get('insights'),
insight_message_distribution)
if configuration.get('next_flight', 'off') == 'on':
next_flight_text = FlightInsightNextFlight(flights, configuration)
if next_flight_text:
insight_messages.insert(0, next_flight_text)
insight_messages = [
(FLAG_MSG_INSIGHT, m, flight) for m in insight_messages]
time_insight_message_inserted = time.time()
for insight_message in insight_messages:
message_queue.insert(0, insight_message)
<----SKIPPED LINES---->
|