Fixed formatting.
This commit is contained in:
@@ -77,7 +77,7 @@ def _format_duration(timestamp_str: str, now: datetime) -> str:
|
||||
return f"{hours} hour{'s' if hours != 1 else ''}"
|
||||
days = seconds // 86400
|
||||
return f"{days} day{'s' if days != 1 else ''}"
|
||||
except (TypeError, ValueError):
|
||||
except TypeError, ValueError:
|
||||
return "unknown duration"
|
||||
|
||||
|
||||
@@ -133,8 +133,7 @@ class CommandHandler:
|
||||
)
|
||||
except NotSubscribedError as e:
|
||||
await evt.reply(
|
||||
"This room is already not subscribed to "
|
||||
f"notifications for {e.domain}."
|
||||
f"This room is already not subscribed to notifications for {e.domain}."
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
@@ -120,8 +120,7 @@ class OwncastClient:
|
||||
async with self.session.get(url, allow_redirects=False) as response:
|
||||
if response.status != 200:
|
||||
self.log.warning(
|
||||
"[%s] Response to request on %s was not 200, "
|
||||
"got %s instead.",
|
||||
"[%s] Response to request on %s was not 200, got %s instead.",
|
||||
domain,
|
||||
path,
|
||||
response.status,
|
||||
@@ -159,9 +158,7 @@ class OwncastClient:
|
||||
)
|
||||
return None
|
||||
except (aiohttp.ClientError, TimeoutError, OSError) as e:
|
||||
self.log.warning(
|
||||
"[%s] Error making GET request to %s: %s", domain, path, e
|
||||
)
|
||||
self.log.warning("[%s] Error making GET request to %s: %s", domain, path, e)
|
||||
return None
|
||||
|
||||
async def get_stream_state(self, domain: str) -> StreamState | None:
|
||||
|
||||
@@ -377,8 +377,7 @@ class StreamMonitor:
|
||||
# Check for 90-day deletion threshold
|
||||
if counter >= _CLEANUP_DELETE_THRESHOLD:
|
||||
self.log.warning(
|
||||
"[%s] Reached 90-day deletion threshold. "
|
||||
"Removing all subscriptions.",
|
||||
"[%s] Reached 90-day deletion threshold. Removing all subscriptions.",
|
||||
domain,
|
||||
)
|
||||
# Send deletion notification
|
||||
@@ -393,8 +392,7 @@ class StreamMonitor:
|
||||
self.notification_service.clear_notification_state(domain)
|
||||
|
||||
self.log.info(
|
||||
"[%s] Cleanup complete. Deleted %s subscriptions "
|
||||
"and stream record.",
|
||||
"[%s] Cleanup complete. Deleted %s subscriptions and stream record.",
|
||||
domain,
|
||||
deleted_count,
|
||||
)
|
||||
|
||||
@@ -87,9 +87,7 @@ class SubscriptionManager:
|
||||
if await self.stream_repo.create(stream_domain):
|
||||
self.log.info("[%s] Discovered new stream!", stream_domain)
|
||||
|
||||
self.log.info(
|
||||
"[%s] Subscription added for room %s.", stream_domain, room_id
|
||||
)
|
||||
self.log.info("[%s] Subscription added for room %s.", stream_domain, room_id)
|
||||
return stream_domain
|
||||
|
||||
async def unsubscribe(self, room_id: str, url: str) -> str:
|
||||
@@ -103,9 +101,7 @@ class SubscriptionManager:
|
||||
stream_domain = _domainify(url)
|
||||
await self.subscription_repo.remove(stream_domain, room_id)
|
||||
|
||||
self.log.info(
|
||||
"[%s] Subscription removed for room %s.", stream_domain, room_id
|
||||
)
|
||||
self.log.info("[%s] Subscription removed for room %s.", stream_domain, room_id)
|
||||
return stream_domain
|
||||
|
||||
async def list_room_subscriptions(self, room_id: str) -> list[RoomSubscription]:
|
||||
|
||||
@@ -423,9 +423,7 @@ class TestResponseTimeMetrics:
|
||||
)
|
||||
await client.get_stream_state("example.com")
|
||||
output = generate_metrics_output(metrics)
|
||||
assert (
|
||||
'owncastsentry_api_response_seconds{domain="example.com"}' in output
|
||||
)
|
||||
assert 'owncastsentry_api_response_seconds{domain="example.com"}' in output
|
||||
finally:
|
||||
await client.close()
|
||||
|
||||
@@ -446,8 +444,7 @@ class TestResponseTimeMetrics:
|
||||
await client.get_stream_state("example.com")
|
||||
output = generate_metrics_output(metrics)
|
||||
assert (
|
||||
'owncastsentry_api_response_seconds{domain="example.com"}'
|
||||
not in output
|
||||
'owncastsentry_api_response_seconds{domain="example.com"}' not in output
|
||||
)
|
||||
finally:
|
||||
await client.close()
|
||||
@@ -469,8 +466,7 @@ class TestResponseTimeMetrics:
|
||||
await client.get_stream_state("example.com")
|
||||
output = generate_metrics_output(metrics)
|
||||
assert (
|
||||
'owncastsentry_api_response_seconds{domain="example.com"}'
|
||||
not in output
|
||||
'owncastsentry_api_response_seconds{domain="example.com"}' not in output
|
||||
)
|
||||
finally:
|
||||
await client.close()
|
||||
|
||||
@@ -117,9 +117,7 @@ class TestHasRoomSubscriptions:
|
||||
self, subscription_repo: SubscriptionRepository
|
||||
) -> None:
|
||||
"""Return False when the room has no subscriptions."""
|
||||
assert not await subscription_repo.has_room_subscriptions(
|
||||
"!nobody:example.com"
|
||||
)
|
||||
assert not await subscription_repo.has_room_subscriptions("!nobody:example.com")
|
||||
|
||||
|
||||
class TestGetRoomSubscriptions:
|
||||
|
||||
Reference in New Issue
Block a user