Refactor for consistent string quoting and formatting
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user