From 868317dabf43bf4c61540793efdb1ef608e5d040 Mon Sep 17 00:00:00 2001 From: dfjera Date: Wed, 20 Mar 2024 18:34:25 +0100 Subject: [PATCH] make settings.py bootstrap compatible with windows --- src/c3nav/settings.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/c3nav/settings.py b/src/c3nav/settings.py index 85f08d29..0437afef 100644 --- a/src/c3nav/settings.py +++ b/src/c3nav/settings.py @@ -109,7 +109,10 @@ if not SECRET_KEY: SECRET_KEY = get_random_string(50, string.printable) with open(SECRET_FILE, 'w') as f: os.chmod(SECRET_FILE, 0o600) - os.chown(SECRET_FILE, os.getuid(), os.getgid()) + try: + os.chown(SECRET_FILE, os.getuid(), os.getgid()) + except AttributeError: + pass f.write(SECRET_KEY) SECRET_TILE_KEY = config.get('c3nav', 'tile_secret', fallback=None) @@ -126,7 +129,10 @@ if not SECRET_TILE_KEY: SECRET_TILE_KEY = get_random_string(50, string.printable) with open(SECRET_TILE_FILE, 'w') as f: os.chmod(SECRET_TILE_FILE, 0o600) - os.chown(SECRET_TILE_FILE, os.getuid(), os.getgid()) + try: + os.chown(SECRET_TILE_FILE, os.getuid(), os.getgid()) + except AttributeError: + pass f.write(SECRET_TILE_KEY) SECRET_MESH_KEY = config.get('c3nav', 'mesh_secret', fallback=None) @@ -143,7 +149,10 @@ if not SECRET_MESH_KEY: SECRET_MESH_KEY = get_random_string(50, string.printable) with open(SECRET_MESH_FILE, 'w') as f: os.chmod(SECRET_MESH_FILE, 0o600) - os.chown(SECRET_MESH_FILE, os.getuid(), os.getgid()) + try: + os.chown(SECRET_MESH_FILE, os.getuid(), os.getgid()) + except AttributeError: + pass f.write(SECRET_MESH_KEY) # Adjustable settings