From b1731e7a4bb2d1e1093b623b1f65dec7f5d8855e Mon Sep 17 00:00:00 2001 From: Ben Hoff Date: Sun, 8 Sep 2019 23:05:01 -0400 Subject: [PATCH] check if keys directory exists before making secret_key --- cvat/settings/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cvat/settings/base.py b/cvat/settings/base.py index 6e2053d19877..ac43a1dfc79c 100644 --- a/cvat/settings/base.py +++ b/cvat/settings/base.py @@ -33,7 +33,10 @@ from keys.secret_key import SECRET_KEY except ImportError: from django.utils.crypto import get_random_string - with open(os.path.join(BASE_DIR, 'keys', 'secret_key.py'), 'w') as f: + keys_dir = os.path.join(BASE_DIR, 'keys') + if not os.path.isdir(keys_dir): + os.mkdir(keys_dir) + with open(os.path.join(keys_dir, 'secret_key.py'), 'w') as f: chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)' f.write("SECRET_KEY = '{}'\n".format(get_random_string(50, chars))) from keys.secret_key import SECRET_KEY