01234567890123456789012345678901234567890123456789012345678901234567890123456789
47454746474747484749475047514752475347544755475647574758475947604761476247634764 47654766 4767 476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794 |
<----SKIPPED LINES---->
histogram_settings.get('histogram_data_summary', False))
if histogram_settings['type'] in ('images', 'both'):
# Since Google Chrome seems to ignore all instructions to not cache, we need
# to make sure we do not reuse file names - hence the epoch_string - and then
# we need to 1) update the histograms.html file with the correct file links, and
# 2) delete the images that are now obsolete.
epoch_string = '%d_' % round(time.time())
generated_histograms = ImageHistograms(
flights,
histogram_settings['histogram'],
histogram_settings['histogram_history'],
filename_prefix=HISTOGRAM_IMAGE_PREFIX + epoch_string)
html_lines = ReadFile(HISTOGRAM_IMAGE_HTML).split('\n')
replaced_images = []
for identifier, new_filename in generated_histograms:
# for each histogram, find the html_line with the matching id
# Example line: <img id='destination' src='images/histogram_destination.png'><p>
n, line = None, None # addresses pylint complaint
for n, line in enumerate(html_lines):
if identifier in line:
break
start_char = line.find(WEBSERVER_IMAGE_FOLDER) + len(WEBSERVER_IMAGE_FOLDER)
end_character = (
line.find(HISTOGRAM_IMAGE_SUFFIX, start_char) + len(HISTOGRAM_IMAGE_SUFFIX))
old_filename = line[start_char:end_character]
line = line.replace(old_filename, new_filename)
html_lines[n] = line
replaced_images.append(line[start_char:end_character])
new_html = '\n'.join(html_lines)
WriteFile(HISTOGRAM_IMAGE_HTML, new_html)
# Remove those obsoleted files
for f in old_filename:
RemoveFile(f)
return histogram_messages
def SaveFlightsByAltitudeDistanceCSV(
flights,
max_days=0,
filename='flights_by_alt_dist.csv',
precision=100):
"""Extracts hourly histogram into text file for a variety of altitudes and distances.
Generates a csv with 26 columns:
- col#1: altitude (in feet)
- col#2: distance (in feet)
<----SKIPPED LINES---->
|
01234567890123456789012345678901234567890123456789012345678901234567890123456789
474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798 |
<----SKIPPED LINES---->
histogram_settings.get('histogram_data_summary', False))
if histogram_settings['type'] in ('images', 'both'):
# Since Google Chrome seems to ignore all instructions to not cache, we need
# to make sure we do not reuse file names - hence the epoch_string - and then
# we need to 1) update the histograms.html file with the correct file links, and
# 2) delete the images that are now obsolete.
epoch_string = '%d_' % round(time.time())
generated_histograms = ImageHistograms(
flights,
histogram_settings['histogram'],
histogram_settings['histogram_history'],
filename_prefix=HISTOGRAM_IMAGE_PREFIX + epoch_string)
html_lines = ReadFile(HISTOGRAM_IMAGE_HTML).split('\n')
replaced_images = []
for identifier, new_filename in generated_histograms:
# for each histogram, find the html_line with the matching id
# Example line: <img id='destination' src='images/histogram_destination.png'><p>
n, line = None, None # addresses pylint complaint
found = False
for n, line in enumerate(html_lines):
if identifier in line:
found = True
break
found = False
if found:
start_char = line.find(WEBSERVER_IMAGE_FOLDER) + len(WEBSERVER_IMAGE_FOLDER)
end_character = (
line.find(HISTOGRAM_IMAGE_SUFFIX, start_char) + len(HISTOGRAM_IMAGE_SUFFIX))
old_filename = line[start_char:end_character]
line = line.replace(old_filename, new_filename)
html_lines[n] = line
replaced_images.append(line[start_char:end_character])
new_html = '\n'.join(html_lines)
WriteFile(HISTOGRAM_IMAGE_HTML, new_html)
# Remove those obsoleted files
for f in old_filename:
RemoveFile(f)
return histogram_messages
def SaveFlightsByAltitudeDistanceCSV(
flights,
max_days=0,
filename='flights_by_alt_dist.csv',
precision=100):
"""Extracts hourly histogram into text file for a variety of altitudes and distances.
Generates a csv with 26 columns:
- col#1: altitude (in feet)
- col#2: distance (in feet)
<----SKIPPED LINES---->
|