Старый postinstall
This commit is contained in:
commit
4337a3f94e
349 changed files with 21945 additions and 0 deletions
|
|
@ -0,0 +1,59 @@
|
|||
import os
|
||||
from dialog import Dialog
|
||||
from postinstall.logger import logger
|
||||
|
||||
logging = logger
|
||||
|
||||
AUTOSTART_FILE = "/usr/share/postinstall/.norestart"
|
||||
|
||||
|
||||
class AutoStartScreen:
|
||||
def __init__(self):
|
||||
self.d = Dialog(dialog="dialog")
|
||||
|
||||
def check_auto_start(self) -> bool:
|
||||
return not os.path.exists(AUTOSTART_FILE)
|
||||
|
||||
def set_auto_start(self, enable: bool) -> None:
|
||||
try:
|
||||
if enable:
|
||||
try:
|
||||
if os.path.exists(AUTOSTART_FILE):
|
||||
os.remove(AUTOSTART_FILE)
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"Ошибка при включении автозапуска: {e}")
|
||||
else:
|
||||
with open(AUTOSTART_FILE, "w") as f:
|
||||
f.write("# Это файл создан для отключения автозапуска\n")
|
||||
except Exception as e:
|
||||
logging.error(f"Ошибка при изменении автозапуска: {e}")
|
||||
|
||||
def show_screen(self):
|
||||
auto_start_enabled = self.check_auto_start()
|
||||
|
||||
code, tags = self.d.checklist(
|
||||
"Выберите действие",
|
||||
choices=[
|
||||
("autostart", "Автозапуск при следующем запуске", auto_start_enabled)
|
||||
],
|
||||
title="Настройки автозапуска",
|
||||
backtitle="Postinstall Configuration",
|
||||
ok_label="Применить",
|
||||
cancel_label="Назад",
|
||||
)
|
||||
|
||||
if code == self.d.OK:
|
||||
self.set_auto_start("autostart" in tags)
|
||||
self.d.msgbox("Изменения сохранены.")
|
||||
else:
|
||||
logging.info("Изменения отменены пользователем.")
|
||||
|
||||
|
||||
def main():
|
||||
auto_start_screen = AutoStartScreen()
|
||||
auto_start_screen.show_screen()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue