diff --git a/alertproviders/http_alert_provider.py b/alertproviders/http_alert_provider.py index 1abb4ee..debf791 100644 --- a/alertproviders/http_alert_provider.py +++ b/alertproviders/http_alert_provider.py @@ -42,7 +42,7 @@ class HTTPAlertProvider(AlertProvider): logging.debug("Polling " + self.name + " alert API...") http_response = requests.get(self._url, headers=HTTP_HEADERS, timeout=(5, 30)) # Check response code was good - if http_response.status_code == 200: + if http_response.ok: # Pass off to the subclass for processing new_alerts = self._http_response_to_alerts(http_response) # Submit the new alerts for processing. There might not be any alerts for the less popular programs. diff --git a/core/lookup_helper.py b/core/lookup_helper.py index 7fe2594..97b6060 100644 --- a/core/lookup_helper.py +++ b/core/lookup_helper.py @@ -5,7 +5,6 @@ import re import urllib.parse from datetime import timedelta -import requests import xmltodict from diskcache import Cache from pyhamtools import LookupLib, Callinfo, callinfo @@ -143,12 +142,16 @@ class LookupHelper: try: logging.info("Downloading Country-files.com cty.plist...") response = SEMI_STATIC_URL_DATA_CACHE.get("https://www.country-files.com/cty/cty.plist", - headers=HTTP_HEADERS).text + headers=HTTP_HEADERS) - with open(self._country_files_cty_plist_download_location, "w") as f: - f.write(response) - f.flush() - return True + if response.ok: + with open(self._country_files_cty_plist_download_location, "w") as f: + f.write(response.text) + f.flush() + return True + else: + logging.warning(f"HTTP {response.status_code} when downloading Country-files.com cty.plist.") + return False except Exception as e: logging.error("Exception when downloading Clublog cty.xml", e) @@ -161,12 +164,16 @@ class LookupHelper: logging.info("Downloading dxcc.json...") response = SEMI_STATIC_URL_DATA_CACHE.get( "https://raw.githubusercontent.com/k0swe/dxcc-json/refs/heads/main/dxcc.json", - headers=HTTP_HEADERS).text + headers=HTTP_HEADERS) - with open(self._dxcc_json_download_location, "w") as f: - f.write(response) - f.flush() - return True + if response.ok: + with open(self._dxcc_json_download_location, "w") as f: + f.write(response.text) + f.flush() + return True + else: + logging.warning(f"HTTP {response.status_code} when downloading dxcc.json.") + return False except Exception as e: logging.error("Exception when downloading dxcc.json", e) @@ -496,14 +503,20 @@ class LookupHelper: for lookup_call in calls_to_try: try: - lookup_response = requests.get( + response = SEMI_STATIC_URL_DATA_CACHE.get( self._qrz_base_url + "?s=" + session_key + "&callsign=" + urllib.parse.quote_plus(lookup_call), - headers=HTTP_HEADERS, timeout=10).content - raw = xmltodict.parse(lookup_response).get("QRZDatabase", {}).get("Callsign") - if raw: - data = _normalize_qrz_data(raw) - self._qrz_callsign_data_cache.add(call, data, expire=604800) # 1 week in seconds - return data + headers=HTTP_HEADERS, timeout=10) + if response.ok: + raw = xmltodict.parse(response.content).get("QRZDatabase", {}).get("Callsign") + if raw: + data = _normalize_qrz_data(raw) + self._qrz_callsign_data_cache.add(call, data, expire=604800) # 1 week in seconds + return data + elif not response.from_cache: + logging.warning("Malformed response looking up callsign %s using QRZ", lookup_call) + elif not response.from_cache: + logging.warning("HTTP %d looking up callsign %s using QRZ", lookup_call) + except (KeyError, ValueError): continue except Exception: @@ -552,12 +565,17 @@ class LookupHelper: for lookup_call in calls_to_try: try: - lookup_data = SEMI_STATIC_URL_DATA_CACHE.get( + response = SEMI_STATIC_URL_DATA_CACHE.get( self._hamqth_base_url + "?id=" + session_id + "&callsign=" + urllib.parse.quote_plus( - lookup_call) + "&prg=" + HAMQTH_PRG, headers=HTTP_HEADERS).content - data = xmltodict.parse(lookup_data)["HamQTH"]["search"] - self._hamqth_callsign_data_cache.add(call, data, expire=604800) # 1 week in seconds - return data + lookup_call) + "&prg=" + HAMQTH_PRG, headers=HTTP_HEADERS) + if response.ok: + data = xmltodict.parse(response.content)["HamQTH"]["search"] + self._hamqth_callsign_data_cache.add(call, data, expire=604800) # 1 week in seconds + return data + elif not response.from_cache: + logging.warning("HTTP %d looking up callsign %s using HamQTH", response.status_code, lookup_call) + return None + except (KeyError, ValueError): continue except Exception: diff --git a/core/sig_utils.py b/core/sig_utils.py index db180dc..339bd4a 100644 --- a/core/sig_utils.py +++ b/core/sig_utils.py @@ -45,144 +45,181 @@ def populate_sig_ref_info(sig_ref): try: if sig.upper() == "POTA": response = SEMI_STATIC_URL_DATA_CACHE.get("https://api.pota.app/park/" + ref_id, headers=HTTP_HEADERS) - if not response.ok: + if response.ok: + data = response.json() + if data: + fullname = str(data["name"]) if "name" in data else None + if fullname and "parktypeDesc" in data and data["parktypeDesc"] != "": + fullname = fullname + " " + data["parktypeDesc"] + sig_ref.name = fullname + sig_ref.url = "https://pota.app/#/park/" + ref_id + sig_ref.grid = data["grid6"] if "grid6" in data else None + sig_ref.latitude = data["latitude"] if "latitude" in data else None + sig_ref.longitude = data["longitude"] if "longitude" in data else None + elif not response.from_cache: + logging.warning("Malformed response looking up %s ref %s", sig, ref_id) + elif not response.from_cache: logging.warning("HTTP %d looking up %s ref %s", response.status_code, sig, ref_id) - data = response.json() if response.ok else None - if data: - fullname = str(data["name"]) if "name" in data else None - if fullname and "parktypeDesc" in data and data["parktypeDesc"] != "": - fullname = fullname + " " + data["parktypeDesc"] - sig_ref.name = fullname - sig_ref.url = "https://pota.app/#/park/" + ref_id - sig_ref.grid = data["grid6"] if "grid6" in data else None - sig_ref.latitude = data["latitude"] if "latitude" in data else None - sig_ref.longitude = data["longitude"] if "longitude" in data else None + elif sig.upper() == "SOTA": response = SEMI_STATIC_URL_DATA_CACHE.get("https://api-db2.sota.org.uk/api/summits/" + ref_id, headers=HTTP_HEADERS) - if not response.ok: + if response.ok: + data = response.json() + if data: + sig_ref.name = data["name"] if "name" in data else None + sig_ref.url = "https://www.sotadata.org.uk/en/summit/" + ref_id + sig_ref.grid = data["locator"] if "locator" in data else None + sig_ref.latitude = data["latitude"] if "latitude" in data else None + sig_ref.longitude = data["longitude"] if "longitude" in data else None + sig_ref.activation_score = data["points"] if "points" in data else None + elif not response.from_cache: + logging.warning("Malformed response looking up %s ref %s", sig, ref_id) + elif not response.from_cache: logging.warning("HTTP %d looking up %s ref %s", response.status_code, sig, ref_id) - data = response.json() if response.ok else None - if data: - sig_ref.name = data["name"] if "name" in data else None - sig_ref.url = "https://www.sotadata.org.uk/en/summit/" + ref_id - sig_ref.grid = data["locator"] if "locator" in data else None - sig_ref.latitude = data["latitude"] if "latitude" in data else None - sig_ref.longitude = data["longitude"] if "longitude" in data else None - sig_ref.activation_score = data["points"] if "points" in data else None + elif sig.upper() == "WWBOTA": response = SEMI_STATIC_URL_DATA_CACHE.get("https://api.wwbota.org/bunkers/" + ref_id, headers=HTTP_HEADERS) - if not response.ok: + if response.ok: + data = response.json() + if data: + sig_ref.name = data["name"] if "name" in data else None + sig_ref.url = "https://bunkerwiki.org/?s=" + ref_id if ref_id.startswith("B/G") else None + sig_ref.grid = data["locator"] if "locator" in data else None + sig_ref.latitude = data["lat"] if "lat" in data else None + sig_ref.longitude = data["long"] if "long" in data else None + elif not response.from_cache: + logging.warning("Malformed response looking up %s ref %s", sig, ref_id) + elif not response.from_cache: logging.warning("HTTP %d looking up %s ref %s", response.status_code, sig, ref_id) - data = response.json() if response.ok else None - if data: - sig_ref.name = data["name"] if "name" in data else None - sig_ref.url = "https://bunkerwiki.org/?s=" + ref_id if ref_id.startswith("B/G") else None - sig_ref.grid = data["locator"] if "locator" in data else None - sig_ref.latitude = data["lat"] if "lat" in data else None - sig_ref.longitude = data["long"] if "long" in data else None + elif sig.upper() == "GMA" or sig.upper() == "ARLHS" or sig.upper() == "ILLW" or sig.upper() == "WCA" or sig.upper() == "MOTA" or sig.upper() == "IOTA": response = SEMI_STATIC_URL_DATA_CACHE.get("https://www.cqgma.org/api/ref/?" + ref_id, headers=HTTP_HEADERS) - if not response.ok: + if response.ok: + data = response.json() + if data: + sig_ref.name = data["name"] if "name" in data else None + sig_ref.url = "https://www.cqgma.org/zinfo.php?ref=" + ref_id + sig_ref.grid = data["locator"] if "locator" in data else None + sig_ref.latitude = data["latitude"] if "latitude" in data else None + sig_ref.longitude = data["longitude"] if "longitude" in data else None + elif not response.from_cache: + logging.warning("Malformed response looking up %s ref %s via GMA", sig, ref_id) + elif not response.from_cache: logging.warning("HTTP %d looking up %s ref %s", response.status_code, sig, ref_id) - data = response.json() if response.ok else None - if data: - sig_ref.name = data["name"] if "name" in data else None - sig_ref.url = "https://www.cqgma.org/zinfo.php?ref=" + ref_id - sig_ref.grid = data["locator"] if "locator" in data else None - sig_ref.latitude = data["latitude"] if "latitude" in data else None - sig_ref.longitude = data["longitude"] if "longitude" in data else None + elif sig.upper() == "WWFF": - wwff_response = SEMI_STATIC_URL_DATA_CACHE.get("https://wwff.co/wwff-data/wwff_directory.csv", - headers=HTTP_HEADERS) - if not wwff_response.ok: - logging.warning("HTTP %d looking up %s ref %s", wwff_response.status_code, sig, ref_id) - return sig_ref - wwff_index = {row["reference"]: row for row in csv.DictReader(wwff_response.content.decode().splitlines())} - row = wwff_index.get(ref_id) - if row: - sig_ref.name = row["name"] if "name" in row else None - sig_ref.url = "https://wwff.co/directory/?showRef=" + ref_id - sig_ref.grid = row["iaruLocator"] if "iaruLocator" in row and row["iaruLocator"] != "-" else None - sig_ref.latitude = float(row["latitude"]) if "latitude" in row and row["latitude"] != "-" else None - sig_ref.longitude = float(row["longitude"]) if "longitude" in row and row["longitude"] != "-" else None + response = SEMI_STATIC_URL_DATA_CACHE.get("https://wwff.co/wwff-data/wwff_directory.csv", + headers=HTTP_HEADERS) + if response.ok: + wwff_index = {row["reference"]: row for row in csv.DictReader(response.content.decode().splitlines())} + row = wwff_index.get(ref_id) + if row: + sig_ref.name = row["name"] if "name" in row else None + sig_ref.url = "https://wwff.co/directory/?showRef=" + ref_id + sig_ref.grid = row["iaruLocator"] if "iaruLocator" in row and row["iaruLocator"] != "-" else None + sig_ref.latitude = float(row["latitude"]) if "latitude" in row and row["latitude"] != "-" else None + sig_ref.longitude = float(row["longitude"]) if "longitude" in row and row[ + "longitude"] != "-" else None + elif not response.from_cache: + logging.warning("WWFF database did not contain data for ref %s", ref_id) + elif not response.from_cache: + logging.warning("HTTP %d looking up %s ref %s", response.status_code, sig, ref_id) + elif sig.upper() == "SIOTA": - siota_response = SEMI_STATIC_URL_DATA_CACHE.get("https://www.silosontheair.com/data/silos.csv", - headers=HTTP_HEADERS) - if not siota_response.ok: - logging.warning("HTTP %d looking up %s ref %s", siota_response.status_code, sig, ref_id) - return sig_ref - siota_index = {row["SILO_CODE"]: row for row in - csv.DictReader(siota_response.content.decode().splitlines())} - row = siota_index.get(ref_id) - if row: - sig_ref.name = row["NAME"] if "NAME" in row else None - sig_ref.grid = row["LOCATOR"] if "LOCATOR" in row else None - sig_ref.latitude = float(row["LAT"]) if "LAT" in row else None - sig_ref.longitude = float(row["LNG"]) if "LNG" in row else None + response = SEMI_STATIC_URL_DATA_CACHE.get("https://www.silosontheair.com/data/silos.csv", + headers=HTTP_HEADERS) + if response.ok: + siota_index = {row["SILO_CODE"]: row for row in + csv.DictReader(response.content.decode().splitlines())} + row = siota_index.get(ref_id) + if row: + sig_ref.name = row["NAME"] if "NAME" in row else None + sig_ref.grid = row["LOCATOR"] if "LOCATOR" in row else None + sig_ref.latitude = float(row["LAT"]) if "LAT" in row else None + sig_ref.longitude = float(row["LNG"]) if "LNG" in row else None + elif not response.from_cache: + logging.warning("SIOTA database did not contain data for ref %s", ref_id) + elif not response.from_cache: + logging.warning("HTTP %d looking up %s ref %s", response.status_code, sig, ref_id) + elif sig.upper() == "WOTA": response = SEMI_STATIC_URL_DATA_CACHE.get("https://www.wota.org.uk/mapping/data/summits.json", headers=HTTP_HEADERS) - if not response.ok: + if response.ok: + data = response.json() + if data: + for feature in data.get("features", []): + if feature["properties"]["wotaId"] == ref_id: + sig_ref.name = feature["properties"]["title"] + # Fudge WOTA URLs. Outlying fell (LDO) URLs don't match their ID numbers but require 214 to be + # added to them + sig_ref.url = "https://www.wota.org.uk/MM_" + ref_id + if ref_id.upper().startswith("LDO-"): + number = int(ref_id.upper().replace("LDO-", "")) + sig_ref.url = "https://www.wota.org.uk/MM_LDO-" + str(number + 214) + sig_ref.grid = feature["properties"]["qthLocator"] + sig_ref.latitude = feature["geometry"]["coordinates"][1] + sig_ref.longitude = feature["geometry"]["coordinates"][0] + break + elif not response.from_cache: + logging.warning("Malformed response looking up %s ref %s", sig, ref_id) + elif not response.from_cache: logging.warning("HTTP %d looking up %s ref %s", response.status_code, sig, ref_id) - data = response.json() if response.ok else None - if data: - for feature in data.get("features", []): - if feature["properties"]["wotaId"] == ref_id: - sig_ref.name = feature["properties"]["title"] - # Fudge WOTA URLs. Outlying fell (LDO) URLs don't match their ID numbers but require 214 to be - # added to them - sig_ref.url = "https://www.wota.org.uk/MM_" + ref_id - if ref_id.upper().startswith("LDO-"): - number = int(ref_id.upper().replace("LDO-", "")) - sig_ref.url = "https://www.wota.org.uk/MM_LDO-" + str(number + 214) - sig_ref.grid = feature["properties"]["qthLocator"] - sig_ref.latitude = feature["geometry"]["coordinates"][1] - sig_ref.longitude = feature["geometry"]["coordinates"][0] - break + elif sig.upper() == "ZLOTA": response = SEMI_STATIC_URL_DATA_CACHE.get("https://ontheair.nz/assets/assets.json", headers=HTTP_HEADERS) - if not response.ok: + if response.ok: + data = response.json() + if isinstance(data, list): + for asset in data: + if asset["code"] == ref_id: + sig_ref.name = asset["name"] + sig_ref.url = "https://ontheair.nz/assets/" + ref_id.replace("/", "_") + try: + sig_ref.grid = latlong_to_locator(asset["y"], asset["x"], 6) + except: + logging.debug("Invalid lat/lon received for reference") + sig_ref.latitude = asset["y"] + sig_ref.longitude = asset["x"] + break + elif not response.from_cache: + logging.warning("Malformed response looking up %s ref %s", sig, ref_id) + elif not response.from_cache: logging.warning("HTTP %d looking up %s ref %s", response.status_code, sig, ref_id) - data = response.json() if response.ok else None - if isinstance(data, list): - for asset in data: - if asset["code"] == ref_id: - sig_ref.name = asset["name"] - sig_ref.url = "https://ontheair.nz/assets/ZLI_OT-030" + ref_id.replace("/", "_") - try: - sig_ref.grid = latlong_to_locator(asset["y"], asset["x"], 6) - except: - logging.debug("Invalid lat/lon received for reference") - sig_ref.latitude = asset["y"] - sig_ref.longitude = asset["x"] - break + elif sig.upper() == "BOTA": if not sig_ref.name: sig_ref.name = sig_ref.id sig_ref.url = "https://www.beachesontheair.com/beaches/" + sig_ref.name.lower().replace(" ", "-") + elif sig.upper() == "LLOTA": response = SEMI_STATIC_URL_DATA_CACHE.get("https://llota.app/api/public/references", headers=HTTP_HEADERS) - if not response.ok: + if response.ok: + data = response.json() + if isinstance(data, list): + for ref in data: + if ref["reference_code"] == ref_id: + sig_ref.name = str(ref["name"]) + sig_ref.url = "https://llota.app/list/ref/" + ref_id + sig_ref.grid = str(ref["grid_locator"]) + ll = locator_to_latlong(sig_ref.grid) + sig_ref.latitude = ll[0] + sig_ref.longitude = ll[1] + break + elif not response.from_cache: + logging.warning("Malformed response looking up %s ref %s", sig, ref_id) + elif not response.from_cache: logging.warning("HTTP %d looking up %s ref %s", response.status_code, sig, ref_id) - data = response.json() if response.ok else None - if isinstance(data, list): - for ref in data: - if ref["reference_code"] == ref_id: - sig_ref.name = str(ref["name"]) - sig_ref.url = "https://llota.app/list/ref/" + ref_id - sig_ref.grid = str(ref["grid_locator"]) - ll = locator_to_latlong(sig_ref.grid) - sig_ref.latitude = ll[0] - sig_ref.longitude = ll[1] - break + elif sig.upper() == "WWTOTA": if not sig_ref.name: sig_ref.name = sig_ref.id sig_ref.url = "https://wwtota.com/seznam/karta_rozhledny.php?ref=" + str(sig_ref.name) + elif sig.upper() == "TILES": # Tiles on the Air just uses Maidenhead 6-digit squares, so ID, Name and Grid are all the same if not sig_ref.name: @@ -193,6 +230,7 @@ def populate_sig_ref_info(sig_ref): ll = locator_to_latlong(str(sig_ref.grid)) sig_ref.latitude = ll[0] sig_ref.longitude = ll[1] + elif sig.upper() == "WAB" or sig.upper() == "WAI": ll = wab_wai_square_to_lat_lon(ref_id) if ll: @@ -202,21 +240,27 @@ def populate_sig_ref_info(sig_ref): sig_ref.latitude = ll[0] sig_ref.longitude = ll[1] except: - logging.debug("Invalid lat/lon received for reference") + logging.warning("Invalid lat/lon received for WAB/WAI reference") + elif sig.upper() == "DME": # Zero-pad to 5 digits to match our source data row = _DME_INDEX.get(ref_id.zfill(5)) if row: sig_ref.name = row["NOMBRE_ACTUAL"] + ", " + row["PROVINCIA"] - sig_ref.latitude = float(row["LATITUD_ETRS89_REGCAN95"].replace(",", ".")) if row.get("LATITUD_ETRS89_REGCAN95") else None - sig_ref.longitude = float(row["LONGITUD_ETRS89_REGCAN95"].replace(",", ".")) if row.get("LONGITUD_ETRS89_REGCAN95") else None + sig_ref.latitude = float(row["LATITUD_ETRS89_REGCAN95"].replace(",", ".")) if row.get( + "LATITUD_ETRS89_REGCAN95") else None + sig_ref.longitude = float(row["LONGITUD_ETRS89_REGCAN95"].replace(",", ".")) if row.get( + "LONGITUD_ETRS89_REGCAN95") else None if sig_ref.latitude and sig_ref.longitude: try: sig_ref.grid = latlong_to_locator(sig_ref.latitude, sig_ref.longitude, 6) except Exception: - logging.debug("Invalid lat/lon received for reference") + logging.warning("Invalid lat/lon received for DME reference") + else: + logging.warning("DME database did not contain data for ref %s", ref_id) + except Exception: - logging.warning("Failed to look up sig_ref info for " + sig + " ref " + ref_id, exc_info=True) + logging.warning("Exception when looking up sig_ref info for " + sig + " ref " + ref_id, exc_info=True) return sig_ref diff --git a/solarconditionsproviders/giroionosonde.py b/solarconditionsproviders/giroionosonde.py index c85960d..b97b1e3 100644 --- a/solarconditionsproviders/giroionosonde.py +++ b/solarconditionsproviders/giroionosonde.py @@ -128,7 +128,7 @@ class GIROIonosonde(SolarConditionsProvider): to_str = to_time.strftime("%Y.%m.%d+%H:%M:%S") url = f"{LGDC_URL}?ursiCode={ursi}&charName=foF2,MUFD,fmin&DMUF=3000&fromDate={from_str}&toDate={to_str}" http_response = requests.get(url, headers=HTTP_HEADERS, timeout=(5, 15)) - if http_response.status_code != 200: + if not http_response.ok: logging.warning(f"HTTP {http_response.status_code} when calling Giro ionosonde API.") return None, None, None return self._parse_all(http_response.text) diff --git a/solarconditionsproviders/http_solar_conditions_provider.py b/solarconditionsproviders/http_solar_conditions_provider.py index b3a0064..0662b07 100644 --- a/solarconditionsproviders/http_solar_conditions_provider.py +++ b/solarconditionsproviders/http_solar_conditions_provider.py @@ -40,7 +40,7 @@ class HTTPSolarConditionsProvider(SolarConditionsProvider): logging.debug("Polling " + self.name + " solar conditions API...") http_response = requests.get(self._url, headers=HTTP_HEADERS, timeout=(5, 30)) # Check response code was good - if http_response.status_code == 200: + if http_response.ok: new_data = self._http_response_to_solar_conditions(http_response) self.update_data(new_data) diff --git a/solarconditionsproviders/kc2gprop.py b/solarconditionsproviders/kc2gprop.py index d1aa1b0..47c6500 100644 --- a/solarconditionsproviders/kc2gprop.py +++ b/solarconditionsproviders/kc2gprop.py @@ -45,7 +45,7 @@ class KC2GProp(SolarConditionsProvider): try: logging.debug("Polling KC2G ionosonde data...") http_response = requests.get(KC2G_URL, headers=HTTP_HEADERS, timeout=(5, 30)) - if http_response.status_code != 200: + if not http_response.ok: logging.warning(f"HTTP {http_response.status_code} when calling KG2G ionosonde API.") return diff --git a/spotproviders/gma.py b/spotproviders/gma.py index 3362ff4..9bb53ee 100644 --- a/spotproviders/gma.py +++ b/spotproviders/gma.py @@ -39,7 +39,7 @@ class GMA(HTTPSpotProvider): de_call=source_spot["SPOTTER"].upper(), # Seen GMA spots with no frequency or with "QRT" in this field freq=float(source_spot["QRG"]) * 1000 if ( - source_spot["QRG"] != "" and source_spot["QRG"] != "QRT") else None, + source_spot["QRG"] != "" and source_spot["QRG"] != "QRT") else None, # Filter out some weird mode strings mode=source_spot["MODE"].upper() if "<>" not in source_spot["MODE"] else None, comment=source_spot["TEXT"], @@ -58,8 +58,8 @@ class GMA(HTTPSpotProvider): try: ref_response = SEMI_STATIC_URL_DATA_CACHE.get(self.REF_INFO_URL_ROOT + source_spot["REF"], headers=HTTP_HEADERS) - # Sometimes this is blank, so handle that - if ref_response.text is not None and ref_response.text != "": + # Sometimes this is blank even if it's a 200 response, so handle that + if ref_response.ok and ref_response.text is not None and ref_response.text != "": ref_info = ref_response.json() # If this is POTA, SOTA or WWFF data we already have it through other means, so ignore. POTA and WWFF # spots come through with reftype=POTA or reftype=WWFF. SOTA is harder to figure out because both SOTA @@ -94,9 +94,17 @@ class GMA(HTTPSpotProvider): spot.sig_refs[0].sig = ref_info["reftype"] spot.sig = ref_info["reftype"] - # Add to our list. Don't worry about de-duping, removing old spots etc. at this point; other code will do - # that for us. + # Add to our list. Don't worry about de-duping, removing old spots etc. at this point; + # other code will do that for us. new_spots.append(spot) + + elif not ref_response.from_cache: + if not ref_response.ok: + logging.warning( + f"HTTP {ref_response.status_code} when looking up GMA ref {source_spot["REF"]}") + else: + logging.warning( + f"GMA API returned a malformed response when looking up ref {source_spot["REF"]}") except: logging.warning("Exception when looking up " + self.REF_INFO_URL_ROOT + source_spot[ "REF"] + ", ignoring this spot for now") diff --git a/spotproviders/http_spot_provider.py b/spotproviders/http_spot_provider.py index 37038c7..f918a77 100644 --- a/spotproviders/http_spot_provider.py +++ b/spotproviders/http_spot_provider.py @@ -42,7 +42,7 @@ class HTTPSpotProvider(SpotProvider): logging.debug("Polling " + self.name + " spot API...") http_response = requests.get(self._url, headers=HTTP_HEADERS, timeout=(5, 30)) # Check response code was good - if http_response.status_code == 200: + if http_response.ok: # Pass off to the subclass for processing new_spots = self._http_response_to_spots(http_response) # Submit the new spots for processing. There might not be any spots for the less popular programs. diff --git a/templates/add_spot.html b/templates/add_spot.html index 56b2739..5eb90aa 100644 --- a/templates/add_spot.html +++ b/templates/add_spot.html @@ -76,7 +76,7 @@ - + diff --git a/templates/alerts.html b/templates/alerts.html index 73f0081..9d79c2d 100644 --- a/templates/alerts.html +++ b/templates/alerts.html @@ -75,7 +75,7 @@ - + diff --git a/templates/bands.html b/templates/bands.html index a4d206f..8ad31ad 100644 --- a/templates/bands.html +++ b/templates/bands.html @@ -75,8 +75,8 @@ - - + + diff --git a/templates/base.html b/templates/base.html index 45842c0..3ffcb45 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,6 +1,6 @@ {% extends "skeleton.html" %} {% block head_extra %} - + @@ -10,10 +10,10 @@ - - - - + + + + {% end %} {% block body %}
diff --git a/templates/conditions.html b/templates/conditions.html index 15273a7..2959b1c 100644 --- a/templates/conditions.html +++ b/templates/conditions.html @@ -284,7 +284,7 @@
- + diff --git a/templates/map.html b/templates/map.html index 2e64fba..0af2128 100644 --- a/templates/map.html +++ b/templates/map.html @@ -95,8 +95,8 @@ - - + + diff --git a/templates/spots.html b/templates/spots.html index 22fc625..e7f3a1d 100644 --- a/templates/spots.html +++ b/templates/spots.html @@ -116,8 +116,8 @@ - - + + diff --git a/templates/status.html b/templates/status.html index 3da2d06..25ccc0a 100644 --- a/templates/status.html +++ b/templates/status.html @@ -59,7 +59,7 @@ - +