autorestart when edit plugin var

This commit is contained in:
jr-k 2024-07-02 10:47:39 +02:00
parent 0acf2d2db9
commit 6c31fc82d0
2 changed files with 14 additions and 4 deletions

View File

@ -1,5 +1,6 @@
import time
import json
import threading
from flask import Flask, render_template, redirect, request, url_for
from typing import Optional
@ -7,6 +8,7 @@ from typing import Optional
from src.service.ModelStore import ModelStore
from src.interface.ObController import ObController
from src.model.entity.User import User
from src.util.utils import restart
class SettingsController(ObController):
@ -75,3 +77,12 @@ class SettingsController(ObController):
if variable.name == 'lang':
self._model_store.lang().set_lang(variable.value)
self._model_store.variable().reload()
if variable.is_from_plugin():
thread = threading.Thread(target=self.plugin_update)
thread.daemon = True
thread.start()
return redirect(url_for('settings_variable_list'))
def plugin_update(self) -> None:
restart()

View File

@ -222,13 +222,12 @@ def clamp(x: float, minimum: float, maximum: float) -> float:
return max(minimum, min(x, maximum))
def restart(debug: bool) -> None:
def restart(debug=False) -> None:
time.sleep(1)
if platform.system().lower() == 'darwin':
if debug:
python = sys.executable
os.execl(python, python, *sys.argv)
python = sys.executable
os.execl(python, python, *sys.argv)
elif am_i_in_docker():
python = sys.executable
os.execl(python, python, *sys.argv)