mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 14:27:42 +00:00
More ruff linter fixes
This commit is contained in:
@@ -30,15 +30,15 @@ class DXCluster(SpotProvider):
|
||||
def __init__(self, provider_config):
|
||||
"""Constructor requires hostname and port"""
|
||||
|
||||
name = provider_config["name"] if "name" in provider_config else "Cluster"
|
||||
name = provider_config.get("name", "Cluster")
|
||||
super().__init__(name, provider_config)
|
||||
self._hostname = provider_config["host"]
|
||||
self._port = provider_config["port"]
|
||||
self._login_prompt = provider_config["login_prompt"] if "login_prompt" in provider_config else "login:"
|
||||
self._login_prompt = provider_config.get("login_prompt", "login:")
|
||||
self._login_callsign = (
|
||||
provider_config["login_callsign"] if "login_callsign" in provider_config else SERVER_OWNER_CALLSIGN
|
||||
provider_config.get("login_callsign", SERVER_OWNER_CALLSIGN)
|
||||
)
|
||||
self._allow_rbn_spots = provider_config["allow_rbn_spots"] if "allow_rbn_spots" in provider_config else False
|
||||
self._allow_rbn_spots = provider_config.get("allow_rbn_spots", False)
|
||||
self._spot_line_pattern = (
|
||||
self._LINE_PATTERN_ALLOW_RBN if self._allow_rbn_spots else self._LINE_PATTERN_EXCLUDE_RBN
|
||||
)
|
||||
|
||||
@@ -148,7 +148,7 @@ class GMA(HTTPSpotProvider):
|
||||
logger.warning(
|
||||
f"GMA API returned a malformed response when looking up ref {source_spot['REF']}"
|
||||
)
|
||||
except:
|
||||
except Exception:
|
||||
logger.exception(
|
||||
f"Exception when looking up {self.REF_INFO_URL_ROOT}{source_spot['REF']}, ignoring this spot for now"
|
||||
)
|
||||
|
||||
@@ -26,7 +26,7 @@ class RBN(SpotProvider):
|
||||
def __init__(self, provider_config):
|
||||
"""Constructor requires port number."""
|
||||
|
||||
name = provider_config["name"] if "name" in provider_config else "RBN"
|
||||
name = provider_config.get("name", "RBN")
|
||||
super().__init__(name, provider_config)
|
||||
self._port = provider_config["port"]
|
||||
self._telnet = None
|
||||
|
||||
@@ -39,7 +39,7 @@ class SpotProvider:
|
||||
spot.infer_missing()
|
||||
self._add_spot(spot)
|
||||
if spots:
|
||||
self.last_spot_time = datetime.fromtimestamp(max(map(lambda s: s.time, spots)), pytz.UTC)
|
||||
self.last_spot_time = datetime.fromtimestamp(max(s.time for s in spots), pytz.UTC)
|
||||
|
||||
def _submit(self, spot):
|
||||
"""Submit a single spot retrieved from the provider. This will be added to the list regardless of its age. Spots
|
||||
|
||||
@@ -20,7 +20,7 @@ class UKPacketNet(HTTPSpotProvider):
|
||||
new_spots = []
|
||||
# Iterate through source data
|
||||
nodes = http_response.json()["nodes"]
|
||||
for callsign, node in nodes.items():
|
||||
for node in nodes.values():
|
||||
# The node corresponse to the spotter here. It has an "mheard" section which indicates which nodes it has
|
||||
# recently heard, which will be our "DX". But "mheard" stations are not necessarily over RF, they could be
|
||||
# via the internet, so we also need to look up the "port" on which the station was heard, and check that it
|
||||
@@ -34,7 +34,7 @@ class UKPacketNet(HTTPSpotProvider):
|
||||
# This is another packet station heard over RF, so we are good to create a Spot object.
|
||||
|
||||
# First build a "full" comment combining some of the extra info
|
||||
comment = listed_port["comment"] if "comment" in listed_port else ""
|
||||
comment = listed_port.get("comment", "")
|
||||
comment = f"{comment} {listed_port['mode']}" if "mode" in listed_port else comment
|
||||
comment = (
|
||||
f"{comment} {listed_port['modulation']}" if "modulation" in listed_port else comment
|
||||
@@ -82,7 +82,7 @@ class UKPacketNet(HTTPSpotProvider):
|
||||
time=datetime.strptime(heard["lastHeard"], "%Y-%m-%d %H:%M:%S")
|
||||
.replace(tzinfo=pytz.UTC)
|
||||
.timestamp(),
|
||||
de_grid=node["location"]["locator"] if "locator" in node["location"] else None,
|
||||
de_grid=node["location"].get("locator", None),
|
||||
de_latitude=node["location"]["coords"]["lat"],
|
||||
de_longitude=node["location"]["coords"]["lon"],
|
||||
)
|
||||
@@ -99,7 +99,7 @@ class UKPacketNet(HTTPSpotProvider):
|
||||
for spot in new_spots:
|
||||
if spot.dx_call in nodes:
|
||||
spot.dx_grid = (
|
||||
nodes[spot.dx_call]["location"]["locator"] if "locator" in nodes[spot.dx_call]["location"] else None
|
||||
nodes[spot.dx_call]["location"].get("locator", None)
|
||||
)
|
||||
spot.dx_latitude = nodes[spot.dx_call]["location"]["coords"]["lat"]
|
||||
spot.dx_longitude = nodes[spot.dx_call]["location"]["coords"]["lon"]
|
||||
|
||||
@@ -64,9 +64,9 @@ class WebsocketSpotProvider(SpotProvider):
|
||||
except Exception:
|
||||
logger.exception(f"Exception processing message from Websocket Spot Provider ({self.name})")
|
||||
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
self.status = "Error"
|
||||
logger.exception(f"Exception in Websocket Spot Provider ({self.name})", e)
|
||||
logger.exception(f"Exception in Websocket Spot Provider ({self.name})")
|
||||
else:
|
||||
self.status = "Disconnected"
|
||||
sleep(5) # Wait before trying to reconnect
|
||||
|
||||
@@ -19,7 +19,6 @@ class WOTA(HTTPSpotProvider):
|
||||
|
||||
POLL_INTERVAL_SEC = 120
|
||||
SPOTS_URL = "https://www.wota.org.uk/spots_rss.php"
|
||||
LIST_URL = "https://www.wota.org.uk/mapping/data/summits.json"
|
||||
RSS_DATE_TIME_FORMAT = "%a, %d %b %Y %H:%M:%S %z"
|
||||
|
||||
def __init__(self, provider_config):
|
||||
@@ -83,8 +82,8 @@ class WOTA(HTTPSpotProvider):
|
||||
)
|
||||
|
||||
new_spots.append(spot)
|
||||
except Exception as e:
|
||||
logger.error("Exception parsing WOTA spot", e)
|
||||
except Exception:
|
||||
logger.exception("Exception parsing WOTA spot")
|
||||
return new_spots
|
||||
|
||||
def can_submit_spot(self, sig):
|
||||
|
||||
@@ -20,7 +20,7 @@ class XOTA(WebsocketSpotProvider):
|
||||
SIG = None
|
||||
|
||||
def __init__(self, provider_config):
|
||||
name = provider_config["name"] if "name" in provider_config else "xOTA"
|
||||
name = provider_config.get("name", "xOTA")
|
||||
super().__init__(name, provider_config, provider_config["url"])
|
||||
self.SIG = str(provider_config["sig"]) if "sig" in provider_config else None
|
||||
self._sig_ref_prefix = str(provider_config["sig_ref_prefix"]) if "sig_ref_prefix" in provider_config else ""
|
||||
|
||||
Reference in New Issue
Block a user