Skip to content

Commit

Permalink
Lint cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jryburn committed Feb 9, 2024
1 parent 934390f commit 2b28155
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions plugins/event_source/kentik_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ async def webhook(request: web.Request) -> web.Response:
try:
payload = await request.json()
except json.JSONDecodeError as exc:
logger.warning("Wrong body request: failed to decode JSON payload: %s", exc)
logger.warning(
"Wrong body request: failed to decode JSON payload: %s", exc
)
raise web.HTTPBadRequest(text="Invalid JSON payload") from None
headers = dict(request.headers)
headers.pop("Authorization", None)
Expand Down Expand Up @@ -84,10 +86,11 @@ def set_app_attr(args: dict[str, Any]) -> dict[str, Any]:
Args containing the host and port
"""
if "host" not in args:
host = "0.0.0.0"
if "port" not in args:
port = 5000
# Not really used since the values are fed in from the main.
# if "host" not in args:
# host = "0.0.0.0"
# if "port" not in args:
# port = 5000
app_attrs = {}
app_attrs["host"] = args.get("host")
app_attrs["port"] = args.get("port")
Expand Down Expand Up @@ -135,7 +138,8 @@ async def main(queue: asyncio.Queue, args: dict[str, Any]) -> None:
await runner.cleanup()

if __name__ == "__main__":
"""MockQueue if running directly."""
# MockQueue is used if running directly
# via python and not part of an Ansible rulebook.

class MockQueue:
"""A fake queue."""
Expand All @@ -148,8 +152,8 @@ async def put(self: "MockQueue", event: dict) -> None:
main(
MockQueue(),
{
"host": "localhost",
"port": 80,
"host": "0.0.0.0",
"port": 5000,
},
),
)
2 changes: 1 addition & 1 deletion rulebooks/kentik_alert_example_rule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
- name: Print out the alert
condition: event.i == 1

## Define the action we should take should the condition be met
## Define the action we should take should the condition be met

action:
run_playbook:
Expand Down

0 comments on commit 2b28155

Please sign in to comment.