Skip to content

Commit

Permalink
Actually get it to work, including self
Browse files Browse the repository at this point in the history
  • Loading branch information
stefankeidel committed Jan 5, 2025
1 parent 12f32b9 commit 688ca8e
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
7 changes: 6 additions & 1 deletion kirkbot/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import abc
import subprocess
import json
from glom import glom
from datetime import datetime, timedelta


Expand Down Expand Up @@ -49,9 +50,13 @@ async def run(self):
data = json.loads(result.stdout)
now = datetime.utcnow()

# devices, including self -- weird structure in JSON
devices = glom(data, 'Peer') # type: ignore
devices['self'] = glom(data, 'Self') # type: ignore

# Check for key expiry in the output
# if less than one month, then alert
for device in data.get("Peer", {}).values():
for device in devices.values():
if "KeyExpiry" in device:
expiry_date = datetime.strptime(device["KeyExpiry"], "%Y-%m-%dT%H:%M:%SZ")

Expand Down
47 changes: 46 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ python = ">=3.11,<3.13"
click = "^8.1.8"
discord-py = "^2.4.0"
psutil = "^6.1.1"
glom = "^24.11.0"


[tool.poetry.group.dev.dependencies]
Expand Down

0 comments on commit 688ca8e

Please sign in to comment.