syncthing-monitor/syncthing_monitor/config_xml.py

21 lines
567 B
Python
Raw Normal View History

2021-01-28 10:56:11 +00:00
from xml.etree import ElementTree as elementTree
def parse_api_key(xml_path):
2021-01-28 10:56:11 +00:00
root = elementTree.parse(xml_path).getroot()
api_key = ''
for gui in root.findall('gui'):
# noinspection SpellCheckingInspection
api_key = gui.find('apikey').text
return api_key
2021-01-28 13:31:25 +00:00
2021-01-31 11:44:45 +00:00
def set_listen_ip_to_any(in_xml_path, out_xml_path, gui_port=8384):
2021-01-28 13:31:25 +00:00
with open(in_xml_path, 'r') as file:
xml = file.read()
2021-01-29 09:07:58 +00:00
xml = xml.replace("127.0.0.1:8384", "0.0.0.0:{0}".format(gui_port))
2021-01-28 13:31:25 +00:00
with open(out_xml_path, 'w') as file:
file.write(xml)