From: Marcus Hoffmann Date: Thu, 14 Sep 2017 00:13:49 +0000 (+0200) Subject: make sure config exists before writing to it X-Git-Tag: 0.9~78^2~2 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=feadc6a565aa4226df38d52e970ecb2382407725;p=fdroidserver.git make sure config exists before writing to it --- diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 182949d9..fe0462c7 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -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()