From 9f1330c59cee37126f202bfcf95115e0d0043c78 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 24 Jul 2024 16:41:19 -0700 Subject: [PATCH] normalizing --- modules/locationdata.py | 10 +++++----- modules/solarconditions.py | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/locationdata.py b/modules/locationdata.py index 8a5cd45..7ccb53a 100644 --- a/modules/locationdata.py +++ b/modules/locationdata.py @@ -40,7 +40,7 @@ def get_tide(lat=0, lon=0): return ERROR_FETCHING_DATA if station_json['stationList'] == [] or station_json['stationList'] is None: - return "no station found" + return ERROR_FETCHING_DATA station_id = station_json['stationList'][0]['stationId'] @@ -100,7 +100,7 @@ def get_weather(lat=0, lon=0, unit=0): table = soup.find('div', id="detailed-forecast-body") if table is None: - return "no weather data found on NOAA for your location" + return ERROR_FETCHING_DATA else: # get rows rows = table.find_all('div', class_="row") @@ -118,7 +118,7 @@ def get_weather(lat=0, lon=0, unit=0): # get any alerts and return the count alerts = getWeatherAlerts(lat, lon) - if alerts == "No weather alerts found" or alerts == ERROR_FETCHING_DATA or alerts == NO_DATA_NOGPS: + if alerts == ERROR_FETCHING_DATA or alerts == NO_DATA_NOGPS: alert = "" alert_num = 0 else: @@ -200,7 +200,7 @@ def getWeatherAlerts(lat=0, lon=0): ) if alerts == "" or alerts == None: - return "No weather alerts found" + return ERROR_FETCHING_DATA # trim off last newline if alerts[-1] == "\n": @@ -253,7 +253,7 @@ def getActiveWeatherAlertsDetail(lat=0, lon=0): alerts = alerts.split("\n***\n")[:ALERT_COUNT] if alerts == "" or alerts == ['']: - return "No weather alerts found" + return ERROR_FETCHING_DATA # trim off last newline if alerts[-1] == "\n": diff --git a/modules/solarconditions.py b/modules/solarconditions.py index e0256f0..b158fb1 100644 --- a/modules/solarconditions.py +++ b/modules/solarconditions.py @@ -20,7 +20,7 @@ def hf_band_conditions(): for i in solarxml.getElementsByTagName("band"): hf_cond += i.getAttribute("time")[0]+i.getAttribute("name") +"="+str(i.childNodes[0].data)+"\n" else: - hf_cond += "error fetching" + hf_cond += ERROR_FETCHING_DATA hf_cond = hf_cond[:-1] # remove the last newline return hf_cond @@ -39,7 +39,7 @@ def solar_conditions(): signalnoise = i.getElementsByTagName("signalnoise")[0].childNodes[0].data solar_cond = "A-Index: " + solar_a_index + "\nK-Index: " + solar_k_index + "\nSunspots: " + sunspots + "\nX-Ray Flux: " + solar_xray + "\nSolar Flux: " + solar_flux + "\nSignal Noise: " + signalnoise else: - solar_cond += "error fetching" + solar_cond += ERROR_FETCHING_DATA return solar_cond def drap_xray_conditions(): @@ -53,7 +53,7 @@ def drap_xray_conditions(): if x_filter in line: xray_flux = line.split(": ")[1] else: - xray_flux += "error fetching" + xray_flux += ERROR_FETCHING_DATA return xray_flux def get_sun(lat=0, lon=0):