Refactor for consistent string quoting and formatting
Some checks failed
Ansible Lint Check / check-ansible (push) Successful in 5s
Nix Format Check / check-format (push) Successful in 1m14s
Python Lint Check / check-python (push) Failing after 7s

This commit is contained in:
2025-09-23 13:53:29 +00:00
parent 2e5a06e9d5
commit 40063cfe6b
4 changed files with 59 additions and 32 deletions

View File

@@ -259,31 +259,25 @@ def get_systemd_timer_status(timer_name):
"""Check if a systemd timer is active and enabled, and get next run time"""
# Check if timer is active (running/waiting)
active_result = subprocess.run(
["sudo", "systemctl", "is-active", timer_name],
capture_output=True,
text=True
["sudo", "systemctl", "is-active", timer_name], capture_output=True, text=True
)
# Check if timer is enabled (will start on boot)
enabled_result = subprocess.run(
["sudo", "systemctl", "is-enabled", timer_name],
capture_output=True,
text=True
["sudo", "systemctl", "is-enabled", timer_name], capture_output=True, text=True
)
# Check corresponding service status
service_name = timer_name.replace('.timer', '.service')
service_name = timer_name.replace(".timer", ".service")
service_result = subprocess.run(
["sudo", "systemctl", "is-active", service_name],
capture_output=True,
text=True
["sudo", "systemctl", "is-active", service_name], capture_output=True, text=True
)
# Get next run time
list_result = subprocess.run(
["sudo", "systemctl", "list-timers", timer_name, "--no-legend"],
capture_output=True,
text=True
text=True,
)
is_active = active_result.returncode == 0
@@ -337,8 +331,10 @@ def cmd_list(args):
systemd_timers = ["borg-backup.timer", "borg-local-sync.timer", "dynamic-dns.timer"]
for timer in systemd_timers:
is_active, is_enabled, next_run, service_status = get_systemd_timer_status(timer)
service_name = timer.replace('.timer', '')
is_active, is_enabled, next_run, service_status = get_systemd_timer_status(
timer
)
service_name = timer.replace(".timer", "")
if service_status in ["activating", "active"]:
# Service is currently running