mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 14:27:42 +00:00
Use ruff linter to fix issues and provide consistent formatting
This commit is contained in:
@@ -37,8 +37,7 @@ class SSESpotProvider(SpotProvider):
|
||||
try:
|
||||
event_source.close()
|
||||
except Exception:
|
||||
logging.exception(
|
||||
f"Exception closing SSE connection for {self.name} during stop()")
|
||||
logging.exception(f"Exception closing SSE connection for {self.name} during stop()")
|
||||
|
||||
if self._thread:
|
||||
self._thread.join(timeout=15)
|
||||
@@ -60,14 +59,20 @@ class SSESpotProvider(SpotProvider):
|
||||
try:
|
||||
logging.debug(f"Connecting to {self.name} spot API...")
|
||||
self.status = "Connecting"
|
||||
with EventSource(self._url, headers=HTTP_HEADERS, latest_event_id=self._last_event_id, timeout=10,
|
||||
on_open=self._on_open, on_error=self._on_error) as event_source:
|
||||
with EventSource(
|
||||
self._url,
|
||||
headers=HTTP_HEADERS,
|
||||
latest_event_id=self._last_event_id,
|
||||
timeout=10,
|
||||
on_open=self._on_open,
|
||||
on_error=self._on_error,
|
||||
) as event_source:
|
||||
self._set_event_source(event_source)
|
||||
try:
|
||||
for event in event_source:
|
||||
if self._stop_event.is_set():
|
||||
break
|
||||
if event.type == 'message':
|
||||
if event.type == "message":
|
||||
try:
|
||||
self._last_event_id = event.last_event_id
|
||||
new_spot = self._sse_message_to_spot(event.data)
|
||||
@@ -80,7 +85,8 @@ class SSESpotProvider(SpotProvider):
|
||||
|
||||
except Exception:
|
||||
logging.exception(
|
||||
f"Exception processing message from SSE Spot Provider ({self.name})")
|
||||
f"Exception processing message from SSE Spot Provider ({self.name})"
|
||||
)
|
||||
finally:
|
||||
self._set_event_source(None)
|
||||
|
||||
@@ -89,7 +95,7 @@ class SSESpotProvider(SpotProvider):
|
||||
logging.exception(f"Exception in SSE Spot Provider ({self.name})")
|
||||
else:
|
||||
self.status = "Disconnected"
|
||||
self._stop_event.wait(timeout=5) # Wait before trying to reconnect
|
||||
self._stop_event.wait(timeout=5) # Wait before trying to reconnect
|
||||
|
||||
def _sse_message_to_spot(self, message_data):
|
||||
"""Convert an SSE message received from the API into a spot. The whole message data is provided here so the subclass
|
||||
|
||||
Reference in New Issue
Block a user