attempt to get it running ...
quits without any error right after starting with no output on either terminal or browser console and nothing on the html page.
This commit is contained in:
@@ -20,7 +20,7 @@ def parse_geonet_title(title):
|
|||||||
|
|
||||||
return title
|
return title
|
||||||
|
|
||||||
def get_earthquakes(min_mmi=8, limit=20, from_today_only=True):
|
def get_earthquakes(min_mmi=1, limit=20, from_today_only=True):
|
||||||
url = "https://api.geonet.org.nz/quakes/services/quake/"
|
url = "https://api.geonet.org.nz/quakes/services/quake/"
|
||||||
try:
|
try:
|
||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
@@ -70,12 +70,12 @@ def get_earthquakes(min_mmi=8, limit=20, from_today_only=True):
|
|||||||
'status': status
|
'status': status
|
||||||
})
|
})
|
||||||
|
|
||||||
all_quakes.sort(key=lambda x: x['utc_timestamp'], reverse=True)
|
all_quakes.sort(key=lambda x: x['utc_timestamp'], reverse=True)
|
||||||
return all_quakes[:limit]
|
return all_quakes[:limit]
|
||||||
|
|
||||||
except requests.exceptioins.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
print(f"Error fetching data from Geonet API: {e}")
|
print(f"Error fetching data from Geonet API: {e}")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def generate_html(quakes, output_file="geonet_earthquakes.html", css_file="style.css"):
|
def generate_html(quakes, output_file="geonet_earthquakes.html", css_file="style.css"):
|
||||||
html_content = f"""
|
html_content = f"""
|
||||||
@@ -108,8 +108,8 @@ def generate_html(quakes, output_file="geonet_earthquakes.html", css_file="style
|
|||||||
mmi_box_content = "X"
|
mmi_box_content = "X"
|
||||||
else:
|
else:
|
||||||
mmi_class_value = min(quake['mmi'] if quake['mmi'] is not None else 0, 11)
|
mmi_class_value = min(quake['mmi'] if quake['mmi'] is not None else 0, 11)
|
||||||
if mmi_class_value >= 8:
|
if mmi_class_value >= 1:
|
||||||
mmi_box_classes = "mmi-8"
|
mmi_box_classes = "mmi-1"
|
||||||
else:
|
else:
|
||||||
mmi_box_classes = f"mmi-{mmi_class_value}"
|
mmi_box_classes = f"mmi-{mmi_class_value}"
|
||||||
mmi_box_content = str(quake['mmi']) if quake['mmi'] is not None else '--'
|
mmi_box_content = str(quake['mmi']) if quake['mmi'] is not None else '--'
|
||||||
@@ -142,17 +142,17 @@ def generate_html(quakes, output_file="geonet_earthquakes.html", css_file="style
|
|||||||
|
|
||||||
with open(output_file, "w", encoding="utf-8") as f:
|
with open(output_file, "w", encoding="utf-8") as f:
|
||||||
f.write(html_content)
|
f.write(html_content)
|
||||||
print(f"Generated {output_file} with {len(quakes)} earthquakes.)
|
print(f"Generated {output_file} with {len(quakes)} earthquakes.")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
output_html_file = "geonet_earthquakes_list.html"
|
output_html_file = "geonet_earthquakes_list.html"
|
||||||
css_file_name = "style.css"
|
css_file_name = "style.css"
|
||||||
min_mmi_threshold = 8
|
min_mmi_threshold = 1
|
||||||
earthquake_limit = 20
|
earthquake_limit = 20
|
||||||
filter_today_only = True
|
filter_today_only = False
|
||||||
update_interval_minutes = 1
|
update_interval_minutes = 1
|
||||||
|
|
||||||
print(f"Starting Geonet Earthquake Display Generator. HTML file: `{output_html_file}`")
|
print(f"Starting Geonet Earthquake Display Generator. HTML file: '{output_html_file}'")
|
||||||
print(f"Updating every {update_interval_minutes} minute(s).")
|
print(f"Updating every {update_interval_minutes} minute(s).")
|
||||||
print(f"Filtering for MMI {min_mmi_threshold}+, max {earthquake_limit} from today (NZT), including deleted events from today.")
|
print(f"Filtering for MMI {min_mmi_threshold}+, max {earthquake_limit} from today (NZT), including deleted events from today.")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user