chiark / gitweb /
make sure config exists before writing to it
authorMarcus Hoffmann <bubuiic@aol.com>
Thu, 14 Sep 2017 00:13:49 +0000 (02:13 +0200)
committerMarcus Hoffmann <bubuiic@aol.com>
Thu, 14 Sep 2017 00:15:57 +0000 (02:15 +0200)
fdroidserver/common.py

index 182949d928ecc8162d29b6e0b385f0b7f451ab97..fe0462c787716973d3a2ca71f0dd916c578e63bc 100644 (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()