This commit is contained in:
Alexey Berezhok
2026-07-20 01:00:35 +03:00
parent e85d945984
commit 6e32005129
5 changed files with 80 additions and 24 deletions

View File

@@ -68,22 +68,42 @@ def Handle(root):
result = True
result_error = CheckModuleExists()
if result_error is None:
for parent in root.iter():
for child in list(parent):
if child.tag == 'textdata' and child.get('name') == 'nginx_mod_rewrite_plugin_msg_info':
parent.remove(child)
result_error = InstallModule()
result = result_error is None
result = result_error is None
if not result:
# Формирование сообщения об ошибке согласно структуре в metadata
error = etree.SubElement(root, "error")
error.set('code', '1')
error.set('type', 'nginx_mod_rewrite_plugin')
error.set('object', 'wrong_value')
param = etree.SubElement(error, 'param')
param.text = 'wrong_value'
param.set('name', 'object')
param.set('type', 'msg')
param = etree.SubElement(error, 'param')
param.set('name', 'value')
param.text = result_error
if not result:
# Формирование сообщения об ошибке согласно структуре в metadata
error = etree.SubElement(root, "error")
error.set('code', '1')
error.set('type', 'nginx_mod_rewrite_plugin')
error.set('object', 'wrong_value')
param = etree.SubElement(error, 'param')
param.text = 'wrong_value'
param.set('name', 'object')
param.set('type', 'msg')
param = etree.SubElement(error, 'param')
param.set('name', 'value')
param.text = result_error
else:
# Add <ok/> element to root
etree.SubElement(root, 'ok')
else:
# Remove textdata element with name="nginx_mod_rewrite_plugin_msg"
for parent in root.iter():
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 = 'Ничего не делать'
if __name__ == "__main__":
@@ -100,6 +120,28 @@ if __name__ == "__main__":
if correct_function:
if os.getenv("PARAM_clicked_button") == "ok":
Handle(root)
else:
result_error = CheckModuleExists()
if result_error is None:
for parent in root.iter():
for child in list(parent):
if child.tag == 'textdata' and child.get('name') == 'nginx_mod_rewrite_plugin_msg_info':
parent.remove(child)
else:
# Remove textdata element with name="nginx_mod_rewrite_plugin_msg"
for parent in root.iter():
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 = 'Ничего не делать'
etree.dump(root)
quit(0)