Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

journald: basic ruff formating #139

Merged
merged 10 commits into from
Aug 3, 2023
27 changes: 21 additions & 6 deletions extensions/eda/plugins/event_source/journald.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,21 @@
from systemd import journal


async def main(queue: asyncio.Queue, args: dict[str, Any]) -> None:
"""Tail systemd journald logs."""
async def main(queue: asyncio.Queue, args: dict[str, Any]) -> str: # noqa: D417
"""Read journal entries and add them to the provided queue.

Args:
----
queue (asyncio.Queue): The queue to which journal entries will be added.
args (dict[str, Any]): Additional arguments:
- delay (int): The delay in seconds. Defaults to 0.
- match (list[str]): A list of strings to match.
Defaults to empty list.

Returns:
-------
None
"""
delay = args.get("delay", 0)
match = args.get("match", [])

Expand All @@ -55,13 +68,15 @@ async def main(queue: asyncio.Queue, args: dict[str, Any]) -> None:


if __name__ == "__main__":
"""MockQueue if running directly."""
"""
Entry point of the program.
"""

class MockQueue:
"""A fake queue."""
"""A mock implementation of a queue that prints the event."""

async def put(self: "MockQueue", event: dict) -> None:
"""Print the event."""
async def put(self: str, event: str) -> str:
"""Add the event to the queue and print it."""
print(event) # noqa: T201

asyncio.run(main(MockQueue(), {"match": "ALL"}))