mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-11-22 12:41:05 +01:00
Refactored timer manager
This commit is contained in:
parent
618e10d94a
commit
6ed733a25c
@ -64,14 +64,16 @@ def manage_timer(service, action):
|
|||||||
raise ValueError("Invalid action specified for manage_timer")
|
raise ValueError("Invalid action specified for manage_timer")
|
||||||
|
|
||||||
timer_name = f"{service}.timer"
|
timer_name = f"{service}.timer"
|
||||||
subprocess.run(['systemctl', action, timer_name])
|
try:
|
||||||
|
subprocess.run(['systemctl', action, timer_name], check=True)
|
||||||
if action == 'start':
|
if action == 'start':
|
||||||
subprocess.run(['systemctl', 'enable', timer_name])
|
subprocess.run(['systemctl', 'enable', timer_name], check=True)
|
||||||
elif action == 'stop':
|
elif action == 'stop':
|
||||||
subprocess.run(['systemctl', 'disable', timer_name])
|
subprocess.run(['systemctl', 'disable', timer_name], check=True)
|
||||||
|
|
||||||
print(f"{timer_name} {action}ed and {'enabled' if action == 'start' else 'disabled'}.")
|
print(f"{timer_name} {action}ed and {'enabled' if action == 'start' else 'disabled'}.")
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print(f"Error managing timer {timer_name}: {e}")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
def stop_timer(service):
|
def stop_timer(service):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user