cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
settings.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 # @COPYRIGHT_begin
3 #
4 # Copyright [2010-2014] Institute of Nuclear Physics PAN, Krakow, Poland
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18 # @COPYRIGHT_end
19 
20 ##
21 # @package src.wi.settings
22 #
23 # @author Piotr Wójcik
24 # @author Krzysztof Danielowski
25 # @date 21.09.2010
26 #
27 
28 try:
29  from defaults import *
30  from config import CLOUD_MANAGER_ADDRESS, LOG_LEVEL, LOG_DIR, WI_DATA, SECRET_KEY
31 except Exception, ex:
32  print "Error importing WI configuration file: config.py\nReason: %s" % str(ex)
33  exit()
34 
35 import json
36 import logging
37 import os
38 
39 from common.states import vm_states, farm_states, image_states, node_states, user_active_states as user_states
40 
41 
42 ALLOWED_HOSTS = ['*']
43 
44 VERSION = '2.2'
45 
46 PROJECT_DIR = os.path.dirname(__file__)
47 
48 #############################################
49 # WI specific settings for cc1 project. #
50 #############################################
51 CAPTCHA = True
52 
53 # priv/pub keys to reCaptcha bound to common account cc1.ifj@gmail.com
54 RECAPTCHA_PUBLIC_KEY = '6LenDtcSAAAAAJLrj1MBBAVGIaOjo3PNFZc7FDc4'
55 RECAPTCHA_PRIVATE_KEY = '6LenDtcSAAAAAKisRsijUTTOEWAtr6yBNg1Cl_AL'
56 
57 # port on which NoVNC proxy is running
58 NOVNC_PORT = 6080
59 
60 
61 # logging
62 LOG_FORMAT = "%(asctime)s %(levelname)s - %(message)s"
63 
64 LOGGING = {
65  'version': 1,
66  'disable_existing_loggers': False,
67  'formatters': {
68  'verbose': {
69  'format': '%(asctime)s %(levelname)s - %(message)s'
70  }
71  },
72  'handlers': {
73  'null': {
74  'level': 'DEBUG',
75  'class': 'django.utils.log.NullHandler',
76  },
77  'console': {
78  'level': 'DEBUG',
79  'class': 'logging.StreamHandler',
80  'formatter': 'verbose'
81  },
82  'wi_logger': {
83  'level': 'DEBUG',
84  'class': 'logging.handlers.TimedRotatingFileHandler',
85  'filename': os.path.join(LOG_DIR, 'wi.log').replace('\\', '/'),
86  'when': 'D',
87  'interval': 1,
88  'formatter': 'verbose'
89  },
90  'request': {
91  'level': 'DEBUG',
92  'class': 'logging.handlers.TimedRotatingFileHandler',
93  'filename': os.path.join(LOG_DIR, 'request.log').replace('\\', '/'),
94  'when': 'D',
95  'interval': 1,
96  'formatter': 'verbose'
97  }
98  },
99  'loggers': {
100  '': {
101  'handlers': ['console'],
102  'propagate': False,
103  'level': 'DEBUG',
104  },
105  'django': {
106  'handlers': ['console'],
107  'propagate': False,
108  'level': 'DEBUG',
109  },
110  'django.db.backends': {
111  'handlers': ['console'],
112  'propagate': False,
113  'level': 'ERROR',
114  },
115  'django.request': {
116  'handlers': ['console'],
117  'level': 'ERROR',
118  'propagate': True,
119  },
120  'wi_logger': {
121  'handlers': ['console', 'wi_logger'],
122  'propagate': False,
123  'level': 'DEBUG',
124  },
125  'request': {
126  'handlers': ['console', 'request'],
127  'propagate': False,
128  'level': 'DEBUG',
129  }
130  }
131 }
132 
133 # js states file
134 
135 JS_STATES_FILE = os.path.join(PROJECT_DIR, 'media/js/states.js').replace('\\', '/')
136 file_js_states = open(JS_STATES_FILE, 'w')
137 file_js_states.write(''.join(('cc1.states.vm = ', json.dumps(vm_states), ';')))
138 file_js_states.write(''.join(('cc1.states.farm = ', json.dumps(farm_states), ';')))
139 file_js_states.write(''.join(('cc1.states.image = ', json.dumps(image_states), ';')))
140 file_js_states.write(''.join(('cc1.states.user = ', json.dumps(user_states), ';')))
141 file_js_states.write(''.join(('cc1.states.node = ', json.dumps(node_states), ';')))
142 file_js_states.close()
143 
144 
145 #############################################
146 # Django specific settings for cc1 project. #
147 #############################################
148 DEBUG = False
149 TEMPLATE_DEBUG = DEBUG
150 
151 WSGI_APPLICATION = 'wi.wsgi.application'
152 
153 ROOT_URLCONF = 'wi.urls'
154 
155 ADMINS = (
156  # ('Your Name', 'your_email@domain.com'),
157 )
158 
159 MANAGERS = ADMINS
160 
161 # Local time zone for this installation. Choices can be found here:
162 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
163 # although not all choices may be available on all operating systems.
164 # On Unix systems, a value of None will cause Django to use the same
165 # timezone as the operating system.
166 # If running in a Windows environment this must be set to the same as your
167 # system time zone.
168 TIME_ZONE = 'Europe/Warsaw'
169 
170 LANGUAGE_CODE = 'pl'
171 
172 ugettext = lambda s: s
173 
174 LANGUAGES = (
175  ('pl', ugettext('Polski')),
176  ('en', ugettext('English')),
177 )
178 
179 SITE_ID = 1
180 
181 TEMPLATE_STRING_IF_INVALID = 'empty'
182 
183 # If you set this to False, Django will make some optimizations so as not
184 # to load the internationalization machinery.
185 USE_I18N = True
186 
187 # If you set this to False, Django will not format dates, numbers and
188 # calendars according to the current locale
189 USE_L10N = True
190 
191 # Absolute path to the directory that holds media.
192 # Example: "/home/media/media.lawrence.com/"
193 MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media')
194 
195 # URL that handles the media served from MEDIA_ROOT. Make sure to use a
196 # trailing slash if there is a path component (optional in other cases).
197 # Examples: "http://media.lawrence.com", "http://example.com/media/"
198 MEDIA_URL = '/media/'
199 
200 # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
201 # trailing slash.
202 # Examples: "http://foo.com/media/", "/media/".
203 ADMIN_MEDIA_PREFIX = '/media/admin/'
204 
205 # List of callables that know how to import templates from various sources.
206 TEMPLATE_LOADERS = (
207  'django.template.loaders.filesystem.Loader',
208  'django.template.loaders.app_directories.Loader',
209 )
210 
211 TEMPLATE_CONTEXT_PROCESSORS = (
212  'django.core.context_processors.i18n',
213  'django.core.context_processors.media',
214  'django.contrib.messages.context_processors.messages',
215  'django.core.context_processors.request',
216  'wi.utils.context_processors.add_variables',
217 )
218 
219 MIDDLEWARE_CLASSES = (
220  'django.contrib.sessions.middleware.SessionMiddleware',
221  'django.middleware.locale.LocaleMiddleware',
222  'django.middleware.common.CommonMiddleware',
223  'django.contrib.messages.middleware.MessageMiddleware',
224  'wi.recaptcha_django.middleware.ReCaptchaMiddleware',
225  'django.middleware.gzip.GZipMiddleware',
226 )
227 
228 LOCALE_PATHS = (
229  os.path.join(PROJECT_DIR, 'locale').replace('\\', '/'),
230 )
231 
232 TEMPLATE_DIRS = (
233  os.path.join(PROJECT_DIR, 'templates').replace('\\', '/'),
234 )
235 
236 INSTALLED_APPS = (
237  'wi.commontags',
238  'wi.recaptcha_django',
239  'wi.utils',
240 )
241 
242 # session settings
243 # SESSION_ENGINE = 'django.contrib.sessions.backends.file'
244 # SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
245 SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
246 SESSION_ENGINE = 'django.contrib.sessions.backends.signed_cookies'
247 
248 SESSION_SAVE_EVERY_REQUEST = True
249 SESSION_EXPIRE_AT_BROWSER_CLOSE = True
250 
251 LOGIN_REDIRECT_URL = '/'
252 LOGIN_URL = '/auth/login/'
253 LOGOUT_URL = '/auth/logout/'
254 
255 MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'
256