forked from macadmins/macnamer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings_import.py
49 lines (45 loc) · 1.61 KB
/
settings_import.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/python
from os import getenv
import locale
# Read list of admins from $DOCKER_MACNAMER_ADMINS env var
admin_list = []
if getenv('DOCKER_MACNAMER_ADMINS'):
admins_var = getenv('DOCKER_MACNAMER_ADMINS')
if ',' in admins_var and ':' in admins_var:
for admin in admins_var.split(':'):
admin_list.append(tuple(admin.split(',')))
ADMINS = tuple(admin_list)
elif ',' in admins_var:
admin_list.append(tuple(admins_var.split(',')))
ADMINS = tuple(admin_list)
else:
ADMINS = (
('Admin User', '[email protected]')
)
# Read the preferred time zone from $DOCKER_MACNAMER_TZ, use system locale or
# set to 'America/New_York' if neither are set
if getenv('DOCKER_MACNAMER_TZ'):
if '/' in getenv('DOCKER_MACNAMER_TZ'):
TIME_ZONE = getenv('DOCKER_MACNAMER_TZ')
else: TIME_ZONE = 'America/New_York'
elif getenv('TZ'):
TIME_ZONE = getenv('TZ')
else:
TIME_ZONE = 'America/New_York'
# Read the preferred language code from $DOCKER_MACNAMER_LANG, use system locale or
# set to 'en_US' if neither are set
if getenv('DOCKER_MACNAMER_LANG'):
if '_' in getenv('DOCKER_MACNAMER_LANG'):
LANGUAGE_CODE = getenv('DOCKER_MACNAMER_LANG')
else:
LANGUAGE_CODE = 'en_US'
# elif locale.getdefaultlocale():
# LANGUAGE_CODE = locale.getdefaultlocale()[0]
else:
LANGUAGE_CODE = 'en_US'
# Read the list of allowed hosts from the $DOCKER_MACNAMER_ALLOWED env var, or
# allow all hosts if none was set.
if getenv('DOCKER_MACNAMER_ALLOWED'):
ALLOWED_HOSTS = getenv('DOCKER_MACNAMER_ALLOWED').split(',')
else:
ALLOWED_HOSTS = ['*']