2024-08-28 22:20:36 +02:00
|
|
|
import questionary
|
|
|
|
from questionary import Choice
|
|
|
|
|
|
|
|
from core.vars import loaded_services
|
|
|
|
|
|
|
|
start = None
|
|
|
|
start_service = None
|
|
|
|
stop_service = None
|
|
|
|
install_service = None
|
|
|
|
uninstall_service = None
|
|
|
|
are_you_sure = None
|
|
|
|
any_key = None
|
2024-08-29 12:03:37 +02:00
|
|
|
already_running = None
|
2024-08-28 22:20:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
def update_choices():
|
2024-08-29 12:03:37 +02:00
|
|
|
global start, start_service, stop_service, install_service, uninstall_service, are_you_sure, any_key, already_running
|
2024-08-28 22:20:36 +02:00
|
|
|
|
|
|
|
start = questionary.select(
|
|
|
|
"Choose an option:",
|
|
|
|
choices=[
|
|
|
|
Choice("Start service"),
|
|
|
|
Choice("Stop service"),
|
|
|
|
Choice("Install/update service"),
|
|
|
|
Choice("Uninstall service"),
|
|
|
|
Choice("exit")
|
|
|
|
])
|
|
|
|
|
2024-08-29 12:26:37 +02:00
|
|
|
_services_choices = [Choice(f"{service.name} [{'ON' if service.status() else 'OFF'}]", value=service.id) for service
|
|
|
|
in loaded_services.values()]
|
|
|
|
|
2024-08-28 22:20:36 +02:00
|
|
|
_services_choices.append(Choice("go back", value="back"))
|
|
|
|
|
|
|
|
start_service = questionary.select(
|
|
|
|
"Select service to start:",
|
|
|
|
choices=_services_choices
|
|
|
|
)
|
|
|
|
|
|
|
|
stop_service = questionary.select(
|
|
|
|
"Select service to stop:",
|
|
|
|
choices=_services_choices
|
|
|
|
)
|
|
|
|
|
|
|
|
install_service = questionary.select(
|
|
|
|
"Select service to install/update:",
|
|
|
|
choices=_services_choices
|
|
|
|
)
|
|
|
|
|
|
|
|
uninstall_service = questionary.select(
|
|
|
|
"Select service to uninstall:",
|
|
|
|
choices=_services_choices
|
|
|
|
)
|
|
|
|
|
|
|
|
are_you_sure = questionary.confirm("Are you sure?")
|
|
|
|
|
2024-08-29 12:03:37 +02:00
|
|
|
already_running = questionary.confirm("Service is already running, do you want to restart it?")
|
|
|
|
|
2024-08-28 22:20:36 +02:00
|
|
|
any_key = questionary.text("Press any key to continue")
|