diff --git a/main.py b/main.py index 3d8c78569dd31fc2769802c5822ff9987931205c..952131f45c15a212d580d784a8f471397ea274e0 100644 --- a/main.py +++ b/main.py @@ -116,24 +116,24 @@ async def get_module_config(module: str): tree = ET.parse("xml_configs/"+module+"_conf.xml") root = tree.getroot() #config = json.dumps(xmltodict.XmlDictConfig(root)) - with open("xml_configs/"+module+"_conf.xml", encoding='utf8') as fd: + with open("xml_configs/"+module+"_conf.xml", encoding='utf-8') as fd: config = json.dumps(xmltodict.parse(fd.read())) return config @app.put("/modules/config/update") async def update_module_config(config: Conf): dict = {"module_configuration_file": config.module_configuration_file} xml = xmltodict.unparse(dict, pretty=True) - print(xml) - with open("xml_configs/" + config.module_configuration_file["@name"], "w") as fd: + with open("xml_configs/" + config.module_configuration_file["@name"], "w", encoding='utf-8') as fd: fd.write(xml) return @app.get("/modules/{module}/config/reset") async def reset_module_config(module:str): - with open("xml_configs/"+module+"_conf_default.xml", encoding='utf8') as fd: - config = json.dumps(xmltodict.parse(fd.read())) - with open("xml_configs/"+module+"_conf.xml", "w") as fd: - fd.write(config) + with open("xml_configs/"+module+"_conf_default.xml", encoding='utf-8') as fd: + dict = xmltodict.parse(fd.read()) + xml = xmltodict.unparse(dict, pretty=True) + with open("xml_configs/"+module+"_conf.xml", "w", encoding='utf-8') as fd: + fd.write(xml) return @app.get("/graph/")