This commit is contained in:
Alexey Berezhok
2026-07-21 00:50:05 +03:00
parent 6e32005129
commit 053d60f354
6 changed files with 69 additions and 26 deletions

View File

@@ -2,10 +2,25 @@
import os
import xml.etree.ElementTree as etree
from xml.dom import minidom
from sys import stdin
import subprocess
import datetime
def dump_all_to_log(root):
log_path = '/usr/local/mgr5/var/nginx-mod-rewrite-plugin.log'
try:
with open(log_path, 'a') as log_file:
timestamp = datetime.datetime.now().isoformat()
xml_str = etree.tostring(root, encoding='unicode')
# Prettyprint the XML
pretty_xml = minidom.parseString(xml_str).toprettyxml(indent=" ")
log_file.write(f"{timestamp} - Dumping XML to log:\n{pretty_xml}\n")
log_file.write(f"{timestamp} - Environment variables:\n")
for key, value in sorted(os.environ.items()):
log_file.write(f"{key}={value}\n")
except Exception:
pass
def CheckModuleExists():
module_path = '/usr/share/nginx/modules/ngx_http_apache_rewrite_module.conf'
@@ -97,13 +112,10 @@ def Handle(root):
for child in list(parent):
if child.tag == 'textdata' and child.get('name') == 'nginx_mod_rewrite_plugin_msg':
parent.remove(child)
# Find the messages element with name "nginx_mod_rewrite_plugin.settings"
messages_elem = root.find(".//messages[@name='nginx_mod_rewrite_plugin.settings']")
if messages_elem is not None:
# Find the msg element with name "msg_create" and change its text
msg_create_elem = messages_elem.find(".//msg[@name='msg_create']")
if msg_create_elem is not None:
msg_create_elem.text = 'Ничего не делать'
for buttons in root.findall(".//buttons"):
for btn in list(buttons):
if btn.tag == 'button' and btn.get('name') == 'ok':
buttons.remove(btn)
if __name__ == "__main__":
@@ -134,14 +146,10 @@ if __name__ == "__main__":
if child.tag == 'textdata' and child.get('name') == 'nginx_mod_rewrite_plugin_msg':
parent.remove(child)
# Find the messages element with name "nginx_mod_rewrite_plugin.settings"
messages_elem = root.find(".//messages[@name='nginx_mod_rewrite_plugin.settings']")
if messages_elem is not None:
# Find the msg element with name "msg_create" and change its text
msg_create_elem = messages_elem.find(".//msg[@name='msg_create']")
if msg_create_elem is not None:
msg_create_elem.text = 'Ничего не делать'
for buttons in root.findall(".//buttons"):
for btn in list(buttons):
if btn.tag == 'button' and btn.get('name') == 'ok':
buttons.remove(btn)
etree.dump(root)
quit(0)