Fix plugin removal and variable handling in main.py of the web UI

This commit is contained in:
Théophile Diot 2024-03-15 10:36:01 +00:00
parent 9fe98c1650
commit 8c3b781e6c
No known key found for this signature in database
GPG key ID: 248FEA4BAE400D06

View file

@ -330,8 +330,9 @@ def run_action(plugin: str, function_name: str = ""):
finally:
if sbin_nginx_path.is_file():
# Remove the custom plugin from the shared library
sys_path.pop()
sys_modules.pop("actions")
if sys_path:
sys_path.pop()
sys_modules.pop("actions", None)
del actions
if message or not isinstance(res, dict) and not res:
@ -813,7 +814,7 @@ def services():
# Check variables
variables = deepcopy(request.form.to_dict())
del variables["csrf_token"]
is_draft = variables.pop("is_draft") == "yes"
is_draft = variables.pop("is_draft", "no") == "yes"
if "OLD_SERVER_NAME" not in request.form and request.form["operation"] == "edit":
return redirect_flash_error("Missing OLD_SERVER_NAME parameter.", "services", True)
@ -1974,7 +1975,7 @@ def bans():
bans = bans[:100]
for ban in bans:
exp = ban.pop("exp")
exp = ban.pop("exp", 0)
# Add remain
ban["remain"], ban["term"] = ("unknown", "unknown") if exp <= 0 else get_remain(exp)
# Convert stamp to date