01234567890123456789012345678901234567890123456789012345678901234567890123456789
58495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889 71927193719471957196719771987199720072017202720372047205720672077208720972107211 72127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234 |
<----SKIPPED LINES---->
if (
running_hours >= min_hours and
not message_queue and
not json_desc_dict.get('radio_range_flights') and
# script /home/pi/splitflap/backup.sh creates temp file in this
# directory; after it is copied to the NAS, it is deleted
not os.listdir('/media/backup')):
msg = ('All quiet reboot triggered based on %d days (%d hours); '
'actual runtime: %.2f hours' %
(restart_days, min_hours, running_hours))
SHUTDOWN_SIGNAL = msg
Log(msg)
reboot = True
# Wait another half day
restart_days += 0.5
min_hours = restart_days * HOURS_IN_DAY
if (
running_hours > min_hours and
not message_queue and
int(EpochDisplayTime(time.time(), '%-H')) >= 4):
msg = ('Early morning reboot triggered based on %.1f (%d hours); '
'actual runtime: %.2f hours' %
(restart_days, min_hours, running_hours))
SHUTDOWN_SIGNAL = msg
Log(msg)
reboot = True
if 'soft_reboot' in configuration:
msg = 'Soft reboot requested via web form'
SHUTDOWN_SIGNAL = msg
Log(msg)
reboot = True
RemoveSetting(configuration, 'soft_reboot')
if 'end_process' in configuration:
msg = 'Process end requested via web form'
SHUTDOWN_SIGNAL = msg
Log(msg)
RemoveSetting(configuration, 'end_process')
<----SKIPPED LINES---->
if initial_memory_dump:
tracemalloc.start(initial_frame_count)
startup_time = time.time()
json_desc_dict = {}
init_timing.append((time.time(), 3))
flights = UnpickleObjectFromFile(
PICKLE_FLIGHTS, True, max_days=MAX_INSIGHT_HORIZON_DAYS, heartbeat=True)
# Clear the loaded flight of any cached data, identified by keys
# with a specific suffix, since code fixes may change the values for
# some of those cached elements
init_timing.append((time.time(), 4))
for flight in flights:
for key in list(flight.keys()):
if key.endswith(CACHED_ELEMENT_PREFIX):
flight.pop(key)
init_timing.append((time.time(), 5))
# We have no use for the memory-hogging persistent_path key of historical
# flights, so let's remove all those keys and save a lot of memory
for flight in flights:
if 'persistent_path' in flight:
del flight['persistent_path']
screen_history = UnpickleObjectFromFile(PICKLE_SCREENS, True, max_days=2)
# If we're displaying just a single insight message, we want it to be
# something unique, to the extent possible; this dict holds a count of
# the diff types of messages displayed so far
insight_message_distribution = {}
# bootstrap the flight insights distribution from a list of insights on each
# flight (i.e.: flight['insight_types'] for a given flight might look like
# [1, 2, 7, 9], or [], to indicate which insights were identified; this then
# transforms that into {0: 25, 1: 18, ...} summing across all flights.
missing_insights = []
for flight in flights:
if 'insight_types' not in flight:
missing_insights.append('%s on %s' % (
DisplayFlightNumber(flight), DisplayTime(flight, '%x %X')))
distribution = flight.get('insight_types', [])
for key in distribution:
insight_message_distribution[key] = (
<----SKIPPED LINES---->
|
01234567890123456789012345678901234567890123456789012345678901234567890123456789
58495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889 71927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235 |
<----SKIPPED LINES---->
if (
running_hours >= min_hours and
not message_queue and
not json_desc_dict.get('radio_range_flights') and
# script /home/pi/splitflap/backup.sh creates temp file in this
# directory; after it is copied to the NAS, it is deleted
not os.listdir('/media/backup')):
msg = ('All quiet reboot triggered based on %d days (%d hours); '
'actual runtime: %.2f hours' %
(restart_days, min_hours, running_hours))
SHUTDOWN_SIGNAL = msg
Log(msg)
reboot = True
# Wait another half day
restart_days += 0.5
min_hours = restart_days * HOURS_IN_DAY
if (
running_hours > min_hours and
not message_queue and
6 >= int(EpochDisplayTime(time.time(), '%-H')) >= 4):
msg = ('Early morning reboot triggered based on %.1f (%d hours); '
'actual runtime: %.2f hours' %
(restart_days, min_hours, running_hours))
SHUTDOWN_SIGNAL = msg
Log(msg)
reboot = True
if 'soft_reboot' in configuration:
msg = 'Soft reboot requested via web form'
SHUTDOWN_SIGNAL = msg
Log(msg)
reboot = True
RemoveSetting(configuration, 'soft_reboot')
if 'end_process' in configuration:
msg = 'Process end requested via web form'
SHUTDOWN_SIGNAL = msg
Log(msg)
RemoveSetting(configuration, 'end_process')
<----SKIPPED LINES---->
if initial_memory_dump:
tracemalloc.start(initial_frame_count)
startup_time = time.time()
json_desc_dict = {}
init_timing.append((time.time(), 3))
flights = UnpickleObjectFromFile(
PICKLE_FLIGHTS, True, max_days=MAX_INSIGHT_HORIZON_DAYS, heartbeat=True)
# Clear the loaded flight of any cached data, identified by keys
# with a specific suffix, since code fixes may change the values for
# some of those cached elements
init_timing.append((time.time(), 4))
for flight in flights:
for key in list(flight.keys()):
if key.endswith(CACHED_ELEMENT_PREFIX):
flight.pop(key)
init_timing.append((time.time(), 5))
# We have no use for the memory-hogging persistent_path key of historical
# flights, so let's remove all those keys and save a lot of memory
if flights:
for flight in flights[:-1]:
if 'persistent_path' in flight:
del flight['persistent_path']
screen_history = UnpickleObjectFromFile(PICKLE_SCREENS, True, max_days=2)
# If we're displaying just a single insight message, we want it to be
# something unique, to the extent possible; this dict holds a count of
# the diff types of messages displayed so far
insight_message_distribution = {}
# bootstrap the flight insights distribution from a list of insights on each
# flight (i.e.: flight['insight_types'] for a given flight might look like
# [1, 2, 7, 9], or [], to indicate which insights were identified; this then
# transforms that into {0: 25, 1: 18, ...} summing across all flights.
missing_insights = []
for flight in flights:
if 'insight_types' not in flight:
missing_insights.append('%s on %s' % (
DisplayFlightNumber(flight), DisplayTime(flight, '%x %X')))
distribution = flight.get('insight_types', [])
for key in distribution:
insight_message_distribution[key] = (
<----SKIPPED LINES---->
|