-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings_local.py
executable file
·104 lines (83 loc) · 2.85 KB
/
settings_local.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
"""
Django settings for QED project when developing.
NOTE: Make sure PyCharm django config is pointing to settings_local.py
instead of settings.py
For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""
from settings import *
import os
import socket
import logging
print('settings_local.py')
# Get machine IP address
MACHINE_ID = "developer"
IN_PROD = False
# Get local machine IP
def get_machine_ip():
try:
_MACHINE_ID = socket.gethostname()
_MACHINE_INFO = socket.gethostbyname_ex(_MACHINE_ID)
print("Development machine INFO: {}".format(_MACHINE_INFO))
except:
print("Unable to get machine IP")
return None
_MACHINE_IP = ""
for ip in _MACHINE_INFO[2]:
if '192' in ip:
_MACHINE_IP = ip
return _MACHINE_IP
MACHINE_IP = get_machine_ip()
# CTS- Boolean for if it's on Nick's local machine or not..
NICK_LOCAL = False
# Define ENVIRONMENTAL VARIABLES
os.environ.update({
'REST_SERVER_8': 'http://134.67.114.8', # 'http://localhost:64399'
'PROJECT_PATH': PROJECT_ROOT,
'SITE_SKIN': 'EPA', # Leave empty ('') for default skin, 'EPA' for EPA skin
'CONTACT_URL': 'https://www.epa.gov/research/forms/contact-us-about-epa-research',
})
# SECURITY WARNING: don't run with debug turned on in production!
TEMPLATE_DEBUG = False
CSRF_USE_SESSIONS = False
if not os.environ.get('UBERTOOL_REST_SERVER'):
# Local REST server within epa intranet
os.environ.update({'UBERTOOL_REST_SERVER': 'http://localhost:7777'})
print("REST backend = http://localhost:7777")
# SECURITY WARNING: we keep the secret key in a shared dropbox directory
try:
with open('secrets/secret_key_django_dropbox.txt') as f:
SECRET_KEY = f.read().strip()
except IOError as e:
print("Could not find secret file")
down_low = 'Shhhhhhhhhhhhhhh'
SECRET_KEY = down_low
ALLOWED_HOSTS = [
'localhost',
'127.0.0.1',
str(MACHINE_IP)
]
print("ALLOWED_HOSTS: {}".format(str(ALLOWED_HOSTS)))
#IS_PUBLIC = True
#IS_PUBLIC = False
WSGI_APPLICATION = 'wsgi_local.application'
DEBUG = True
# Log to console in Debug mode
if DEBUG:
import logging
logging.basicConfig(
level = logging.DEBUG,
format = '%(asctime)s %(levelname)s %(message)s',
)
# Authentication
if os.environ.get('PASSWORD_REQUIRED') == "True":
logging.warning("Password protection enabled")
MIDDLEWARE += [
'login_middleware.RequireLoginMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
]
AUTH = True
REQUIRE_LOGIN_PATH = '/login/'
SESSION_EXPIRE_AT_BROWSER_CLOSE = True