From 664e0af2077b871c49ee78d612941da630213ad9 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Sun, 4 Feb 2024 22:22:55 +0100 Subject: [PATCH] fix tmp paths, add write_conf method (xml, json, yaml) --- deefuzzer/tools/utils.py | 18 ++++++++++++++++++ example/deefuzzer_webm_file.json | 4 ++-- example/deefuzzer_webm_relay.json | 4 ++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/deefuzzer/tools/utils.py b/deefuzzer/tools/utils.py index 7b70857..f2573c5 100644 --- a/deefuzzer/tools/utils.py +++ b/deefuzzer/tools/utils.py @@ -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: diff --git a/example/deefuzzer_webm_file.json b/example/deefuzzer_webm_file.json index a3b8ef4..3a4433f 100644 --- a/example/deefuzzer_webm_file.json +++ b/example/deefuzzer_webm_file.json @@ -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, diff --git a/example/deefuzzer_webm_relay.json b/example/deefuzzer_webm_relay.json index 7e96520..678c462 100644 --- a/example/deefuzzer_webm_relay.json +++ b/example/deefuzzer_webm_relay.json @@ -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, -- 2.47.3