Avoid using temp_dir for anatric xml config preview
This commit is contained in:
parent
60787bccb7
commit
67853b8db4
@ -59,6 +59,9 @@ class AnatricConfig:
|
|||||||
def save_as(self, filename):
|
def save_as(self, filename):
|
||||||
self._tree.write(filename)
|
self._tree.write(filename)
|
||||||
|
|
||||||
|
def tostring(self):
|
||||||
|
return ET.tostring(self._tree.getroot(), encoding="unicode")
|
||||||
|
|
||||||
def _get_attr(self, name, tag, attr):
|
def _get_attr(self, name, tag, attr):
|
||||||
elem = self._tree.find(name).find(tag)
|
elem = self._tree.find(name).find(tag)
|
||||||
if elem is None:
|
if elem is None:
|
||||||
|
@ -389,11 +389,7 @@ def create():
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def update_config():
|
async def update_config():
|
||||||
with tempfile.TemporaryDirectory() as temp_dir:
|
output_config.value = config.tostring()
|
||||||
temp_file = temp_dir + "/config.xml"
|
|
||||||
config.save_as(temp_file)
|
|
||||||
with open(temp_file) as f_config:
|
|
||||||
output_config.value = f_config.read()
|
|
||||||
|
|
||||||
doc.add_periodic_callback(update_config, 1000)
|
doc.add_periodic_callback(update_config, 1000)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user