From cb5dbcd487e4d7616b16d2961ce1361471dd76b8 Mon Sep 17 00:00:00 2001 From: bryce Date: Tue, 22 Jul 2025 20:09:44 +1200 Subject: [PATCH] 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. --- generate_earthquakes.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/generate_earthquakes.py b/generate_earthquakes.py index b6ff183..9ef64ea 100644 --- a/generate_earthquakes.py +++ b/generate_earthquakes.py @@ -20,7 +20,7 @@ def parse_geonet_title(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/" try: response = requests.get(url) @@ -70,12 +70,12 @@ def get_earthquakes(min_mmi=8, limit=20, from_today_only=True): 'status': status }) - all_quakes.sort(key=lambda x: x['utc_timestamp'], reverse=True) - return all_quakes[:limit] + all_quakes.sort(key=lambda x: x['utc_timestamp'], reverse=True) + return all_quakes[:limit] - except requests.exceptioins.RequestException as e: - print(f"Error fetching data from Geonet API: {e}") - return [] + except requests.exceptions.RequestException as e: + print(f"Error fetching data from Geonet API: {e}") + return [] def generate_html(quakes, output_file="geonet_earthquakes.html", css_file="style.css"): html_content = f""" @@ -108,8 +108,8 @@ def generate_html(quakes, output_file="geonet_earthquakes.html", css_file="style mmi_box_content = "X" else: mmi_class_value = min(quake['mmi'] if quake['mmi'] is not None else 0, 11) - if mmi_class_value >= 8: - mmi_box_classes = "mmi-8" + if mmi_class_value >= 1: + mmi_box_classes = "mmi-1" else: mmi_box_classes = f"mmi-{mmi_class_value}" 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: 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__": output_html_file = "geonet_earthquakes_list.html" css_file_name = "style.css" - min_mmi_threshold = 8 + min_mmi_threshold = 1 earthquake_limit = 20 - filter_today_only = True + filter_today_only = False 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"Filtering for MMI {min_mmi_threshold}+, max {earthquake_limit} from today (NZT), including deleted events from today.")