syncthing-monitor/syncthing_monitor/config_xml.py
2021-01-28 15:33:21 +02:00

21 lines
621 B
Python

from xml.etree import ElementTree as elementTree
def parse_api_key(xml_path='/config/config.xml'):
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
def set_listen_ip_to_any(in_xml_path='/config/config.xml', out_xml_path='/config/config.xml', gui_port='8384'):
with open(in_xml_path, 'r') as file:
xml = file.read()
xml = xml.replace("127.0.0.1:8384", "0.0.0.0:"+gui_port)
with open(out_xml_path, 'w') as file:
file.write(xml)