]> git.parisson.com Git - deefuzzer.git/commitdiff
fix tmp paths, add write_conf method (xml, json, yaml)
authorGuillaume Pellerin <guillaume.pellerin@free.fr>
Sun, 4 Feb 2024 21:22:55 +0000 (22:22 +0100)
committerGuillaume Pellerin <guillaume.pellerin@free.fr>
Sun, 4 Feb 2024 21:22:55 +0000 (22:22 +0100)
deefuzzer/tools/utils.py
example/deefuzzer_webm_file.json
example/deefuzzer_webm_relay.json

index 7b708570e8b0b4841354ff0ce292fd8f9859ce72..f2573c51fe225711761648fe1d40f285f4df6d46 100644 (file)
@@ -111,6 +111,24 @@ def get_conf_dict(file):
     return False
 
 
+def write_conf(conf_dict, path):
+    filename, ext = os.path.splitext(path)
+
+    if 'xml' in ext:
+        xml_data = dicttoxml(conf_dict)
+        f = open(path, 'w')
+        f = confile.write(xml_data)
+        f.close()
+
+    elif 'yaml' in ext or 'yml' in ext:
+        import yaml
+        yaml.dump(conf_dict, path)
+
+    elif 'json' in ext:
+        import json
+        json.dump(conf_dict, path)
+
+
 def folder_contains_music(folder):
     files = os.listdir(folder)
     for file in files:
index a3b8ef4d957a36c06c0f0fe1a25e3461c77daf58..3a4433fbbcafbfb5c8c762788ebf9848da188664 100644 (file)
@@ -1,7 +1,7 @@
 {
     "deefuzzer": {
-        "log": "~/tmp/station.log",
-        "m3u": "~/tmp/station.m3u",
+        "log": "/tmp/station.log",
+        "m3u": "/tmp/station.m3u",
         "stationdefaults": {
             "control": {
                 "mode": 0,
index 7e96520283599a290fe21ed96d1e2c04cdc1d66b..678c462f65430fe3785e0a676a7f4ec3ebe03afd 100644 (file)
@@ -1,7 +1,7 @@
 {
     "deefuzzer": {
-        "log": "~/tmp/station.log",
-        "m3u": "~/tmp/station.m3u",
+        "log": "/tmp/station.log",
+        "m3u": "/tmp/station.m3u",
         "stationdefaults": {
             "control": {
                 "mode": 0,