1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-14 02:50:12 +01:00

make sure config exists before writing to it

This commit is contained in:
Marcus Hoffmann 2017-09-14 02:13:49 +02:00
parent de1afc3c7e
commit feadc6a565

View File

@ -2314,7 +2314,10 @@ def write_to_config(thisconfig, key, value=None, config_file=None):
value = thisconfig[origkey] if origkey in thisconfig else thisconfig[key]
cfg = config_file if config_file else 'config.py'
# load config file
# load config file, create one if it doesn't exist
if not os.path.exists(cfg):
os.mknod(cfg)
logging.info("Creating empty " + cfg)
with open(cfg, 'r', encoding="utf-8") as f:
lines = f.readlines()