diff options
author | Tudor Florea <tudor.florea@enea.com> | 2015-10-09 22:59:03 +0200 |
---|---|---|
committer | Tudor Florea <tudor.florea@enea.com> | 2015-10-09 22:59:03 +0200 |
commit | 972dcfcdbfe75dcfeb777150c136576cf1a71e99 (patch) | |
tree | 97a61cd7e293d7ae9d56ef7ed0f81253365bb026 /bitbake/lib/toaster/toastermain/settings.py | |
download | poky-972dcfcdbfe75dcfeb777150c136576cf1a71e99.tar.gz |
initial commit for Enea Linux 5.0 arm
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'bitbake/lib/toaster/toastermain/settings.py')
-rw-r--r-- | bitbake/lib/toaster/toastermain/settings.py | 304 |
1 files changed, 304 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/toastermain/settings.py b/bitbake/lib/toaster/toastermain/settings.py new file mode 100644 index 0000000000..42581f2df4 --- /dev/null +++ b/bitbake/lib/toaster/toastermain/settings.py | |||
@@ -0,0 +1,304 @@ | |||
1 | # | ||
2 | # ex:ts=4:sw=4:sts=4:et | ||
3 | # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- | ||
4 | # | ||
5 | # BitBake Toaster Implementation | ||
6 | # | ||
7 | # Copyright (C) 2013 Intel Corporation | ||
8 | # | ||
9 | # This program is free software; you can redistribute it and/or modify | ||
10 | # it under the terms of the GNU General Public License version 2 as | ||
11 | # published by the Free Software Foundation. | ||
12 | # | ||
13 | # This program is distributed in the hope that it will be useful, | ||
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | # GNU General Public License for more details. | ||
17 | # | ||
18 | # You should have received a copy of the GNU General Public License along | ||
19 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
21 | |||
22 | # Django settings for Toaster project. | ||
23 | |||
24 | DEBUG = True | ||
25 | TEMPLATE_DEBUG = DEBUG | ||
26 | |||
27 | ADMINS = ( | ||
28 | # ('Your Name', 'your_email@example.com'), | ||
29 | ) | ||
30 | |||
31 | MANAGERS = ADMINS | ||
32 | |||
33 | DATABASES = { | ||
34 | 'default': { | ||
35 | 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. | ||
36 | 'NAME': 'toaster.sqlite', # Or path to database file if using sqlite3. | ||
37 | 'USER': '', | ||
38 | 'PASSWORD': '', | ||
39 | 'HOST': '127.0.0.1', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP. | ||
40 | 'PORT': '3306', # Set to empty string for default. | ||
41 | } | ||
42 | } | ||
43 | |||
44 | # Reinterpret database settings if we have DATABASE_URL environment variable defined | ||
45 | import os, re | ||
46 | |||
47 | if 'DATABASE_URL' in os.environ: | ||
48 | dburl = os.environ['DATABASE_URL'] | ||
49 | if dburl.startswith('sqlite3://'): | ||
50 | result = re.match('sqlite3://(.*)', dburl) | ||
51 | if result is None: | ||
52 | raise Exception("ERROR: Could not read sqlite database url: %s" % dburl) | ||
53 | DATABASES['default'] = { | ||
54 | 'ENGINE': 'django.db.backends.sqlite3', | ||
55 | 'NAME': result.group(1), | ||
56 | 'USER': '', | ||
57 | 'PASSWORD': '', | ||
58 | 'HOST': '', | ||
59 | 'PORT': '', | ||
60 | } | ||
61 | elif dburl.startswith('mysql://'): | ||
62 | # URL must be in this form: mysql://user:pass@host:port/name | ||
63 | result = re.match(r"mysql://([^:]*):([^@]*)@([^:]*):(\d+)/([^/]*)", dburl) | ||
64 | if result is None: | ||
65 | raise Exception("ERROR: Could not read mysql database url: %s" % dburl) | ||
66 | DATABASES['default'] = { | ||
67 | 'ENGINE': 'django.db.backends.mysql', | ||
68 | 'NAME': result.group(5), | ||
69 | 'USER': result.group(1), | ||
70 | 'PASSWORD': result.group(2), | ||
71 | 'HOST': result.group(3), | ||
72 | 'PORT': result.group(4), | ||
73 | } | ||
74 | else: | ||
75 | raise Exception("FIXME: Please implement missing database url schema for url: %s" % dburl) | ||
76 | |||
77 | |||
78 | if 'TOASTER_MANAGED' in os.environ and os.environ['TOASTER_MANAGED'] == "1": | ||
79 | MANAGED = True | ||
80 | else: | ||
81 | MANAGED = False | ||
82 | |||
83 | # Allows current database settings to be exported as a DATABASE_URL environment variable value | ||
84 | |||
85 | def getDATABASE_URL(): | ||
86 | d = DATABASES['default'] | ||
87 | if d['ENGINE'] == 'django.db.backends.sqlite3': | ||
88 | if d['NAME'] == ':memory:': | ||
89 | return 'sqlite3://:memory:' | ||
90 | elif d['NAME'].startswith("/"): | ||
91 | return 'sqlite3://' + d['NAME'] | ||
92 | return "sqlite3://" + os.path.join(os.getcwd(), d['NAME']) | ||
93 | |||
94 | elif d['ENGINE'] == 'django.db.backends.mysql': | ||
95 | return "mysql://" + d['USER'] + ":" + d['PASSWORD'] + "@" + d['HOST'] + ":" + d['PORT'] + "/" + d['NAME'] | ||
96 | |||
97 | raise Exception("FIXME: Please implement missing database url schema for engine: %s" % d['ENGINE']) | ||
98 | |||
99 | |||
100 | |||
101 | # Hosts/domain names that are valid for this site; required if DEBUG is False | ||
102 | # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts | ||
103 | ALLOWED_HOSTS = [] | ||
104 | |||
105 | # Local time zone for this installation. Choices can be found here: | ||
106 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name | ||
107 | # although not all choices may be available on all operating systems. | ||
108 | # In a Windows environment this must be set to your system time zone. | ||
109 | |||
110 | # Always use local computer's time zone, find | ||
111 | import hashlib | ||
112 | if 'TZ' in os.environ: | ||
113 | TIME_ZONE = os.environ['TZ'] | ||
114 | else: | ||
115 | # need to read the /etc/localtime file which is the libc standard | ||
116 | # and do a reverse-mapping to /usr/share/zoneinfo/; | ||
117 | # since the timezone may match any number of identical timezone definitions, | ||
118 | |||
119 | zonefilelist = {} | ||
120 | ZONEINFOPATH = '/usr/share/zoneinfo/' | ||
121 | for dirpath, dirnames, filenames in os.walk(ZONEINFOPATH): | ||
122 | for fn in filenames: | ||
123 | filepath = os.path.join(dirpath, fn) | ||
124 | zonename = filepath.lstrip(ZONEINFOPATH).strip() | ||
125 | try: | ||
126 | import pytz | ||
127 | from pytz.exceptions import UnknownTimeZoneError | ||
128 | pass | ||
129 | try: | ||
130 | if pytz.timezone(zonename) is not None: | ||
131 | zonefilelist[hashlib.md5(open(filepath).read()).hexdigest()] = zonename | ||
132 | except UnknownTimeZoneError, ValueError: | ||
133 | # we expect timezone failures here, just move over | ||
134 | pass | ||
135 | except ImportError: | ||
136 | zonefilelist[hashlib.md5(open(filepath).read()).hexdigest()] = zonename | ||
137 | |||
138 | TIME_ZONE = zonefilelist[hashlib.md5(open('/etc/localtime').read()).hexdigest()] | ||
139 | |||
140 | # Language code for this installation. All choices can be found here: | ||
141 | # http://www.i18nguy.com/unicode/language-identifiers.html | ||
142 | LANGUAGE_CODE = 'en-us' | ||
143 | |||
144 | SITE_ID = 1 | ||
145 | |||
146 | # If you set this to False, Django will make some optimizations so as not | ||
147 | # to load the internationalization machinery. | ||
148 | USE_I18N = True | ||
149 | |||
150 | # If you set this to False, Django will not format dates, numbers and | ||
151 | # calendars according to the current locale. | ||
152 | USE_L10N = True | ||
153 | |||
154 | # If you set this to False, Django will not use timezone-aware datetimes. | ||
155 | USE_TZ = True | ||
156 | |||
157 | # Absolute filesystem path to the directory that will hold user-uploaded files. | ||
158 | # Example: "/var/www/example.com/media/" | ||
159 | MEDIA_ROOT = '' | ||
160 | |||
161 | # URL that handles the media served from MEDIA_ROOT. Make sure to use a | ||
162 | # trailing slash. | ||
163 | # Examples: "http://example.com/media/", "http://media.example.com/" | ||
164 | MEDIA_URL = '' | ||
165 | |||
166 | # Absolute path to the directory static files should be collected to. | ||
167 | # Don't put anything in this directory yourself; store your static files | ||
168 | # in apps' "static/" subdirectories and in STATICFILES_DIRS. | ||
169 | # Example: "/var/www/example.com/static/" | ||
170 | STATIC_ROOT = '' | ||
171 | |||
172 | # URL prefix for static files. | ||
173 | # Example: "http://example.com/static/", "http://static.example.com/" | ||
174 | STATIC_URL = '/static/' | ||
175 | |||
176 | # Additional locations of static files | ||
177 | STATICFILES_DIRS = ( | ||
178 | # Put strings here, like "/home/html/static" or "C:/www/django/static". | ||
179 | # Always use forward slashes, even on Windows. | ||
180 | # Don't forget to use absolute paths, not relative paths. | ||
181 | ) | ||
182 | |||
183 | # List of finder classes that know how to find static files in | ||
184 | # various locations. | ||
185 | STATICFILES_FINDERS = ( | ||
186 | 'django.contrib.staticfiles.finders.FileSystemFinder', | ||
187 | 'django.contrib.staticfiles.finders.AppDirectoriesFinder', | ||
188 | # 'django.contrib.staticfiles.finders.DefaultStorageFinder', | ||
189 | ) | ||
190 | |||
191 | # Make this unique, and don't share it with anybody. | ||
192 | SECRET_KEY = 'NOT_SUITABLE_FOR_HOSTED_DEPLOYMENT' | ||
193 | |||
194 | # List of callables that know how to import templates from various sources. | ||
195 | TEMPLATE_LOADERS = ( | ||
196 | 'django.template.loaders.filesystem.Loader', | ||
197 | 'django.template.loaders.app_directories.Loader', | ||
198 | # 'django.template.loaders.eggs.Loader', | ||
199 | ) | ||
200 | |||
201 | MIDDLEWARE_CLASSES = ( | ||
202 | 'django.middleware.common.CommonMiddleware', | ||
203 | 'django.contrib.sessions.middleware.SessionMiddleware', | ||
204 | 'django.middleware.csrf.CsrfViewMiddleware', | ||
205 | 'django.contrib.auth.middleware.AuthenticationMiddleware', | ||
206 | 'django.contrib.messages.middleware.MessageMiddleware', | ||
207 | # Uncomment the next line for simple clickjacking protection: | ||
208 | # 'django.middleware.clickjacking.XFrameOptionsMiddleware', | ||
209 | ) | ||
210 | |||
211 | ROOT_URLCONF = 'toastermain.urls' | ||
212 | |||
213 | # Python dotted path to the WSGI application used by Django's runserver. | ||
214 | WSGI_APPLICATION = 'toastermain.wsgi.application' | ||
215 | |||
216 | TEMPLATE_DIRS = ( | ||
217 | # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". | ||
218 | # Always use forward slashes, even on Windows. | ||
219 | # Don't forget to use absolute paths, not relative paths. | ||
220 | ) | ||
221 | |||
222 | TEMPLATE_CONTEXT_PROCESSORS = ('django.contrib.auth.context_processors.auth', | ||
223 | 'django.core.context_processors.debug', | ||
224 | 'django.core.context_processors.i18n', | ||
225 | 'django.core.context_processors.media', | ||
226 | 'django.core.context_processors.static', | ||
227 | 'django.core.context_processors.tz', | ||
228 | 'django.contrib.messages.context_processors.messages', | ||
229 | "django.core.context_processors.request", | ||
230 | 'toastergui.views.managedcontextprocessor', | ||
231 | ) | ||
232 | |||
233 | INSTALLED_APPS = ( | ||
234 | #'django.contrib.sites', | ||
235 | 'django.contrib.staticfiles', | ||
236 | # Uncomment the next line to enable admin documentation: | ||
237 | # 'django.contrib.admindocs', | ||
238 | 'django.contrib.humanize', | ||
239 | 'orm', | ||
240 | 'toastermain', | ||
241 | 'south', | ||
242 | ) | ||
243 | |||
244 | SOUTH_TESTS_MIGRATE = False | ||
245 | |||
246 | # if we run in managed mode, we need user support | ||
247 | if MANAGED: | ||
248 | INSTALLED_APPS = ('django.contrib.auth', | ||
249 | 'django.contrib.contenttypes', | ||
250 | 'django.contrib.messages', | ||
251 | 'django.contrib.sessions', | ||
252 | # Uncomment the next line to enable the admin: | ||
253 | 'django.contrib.admin', | ||
254 | ) + INSTALLED_APPS | ||
255 | |||
256 | |||
257 | # We automatically detect and install applications here if | ||
258 | # they have a 'models.py' or 'views.py' file | ||
259 | import os | ||
260 | currentdir = os.path.dirname(__file__) | ||
261 | for t in os.walk(os.path.dirname(currentdir)): | ||
262 | modulename = os.path.basename(t[0]) | ||
263 | if ("views.py" in t[2] or "models.py" in t[2]) and not modulename in INSTALLED_APPS: | ||
264 | INSTALLED_APPS = INSTALLED_APPS + (modulename,) | ||
265 | |||
266 | # A sample logging configuration. The only tangible logging | ||
267 | # performed by this configuration is to send an email to | ||
268 | # the site admins on every HTTP 500 error when DEBUG=False. | ||
269 | # See http://docs.djangoproject.com/en/dev/topics/logging for | ||
270 | # more details on how to customize your logging configuration. | ||
271 | LOGGING = { | ||
272 | 'version': 1, | ||
273 | 'disable_existing_loggers': False, | ||
274 | 'filters': { | ||
275 | 'require_debug_false': { | ||
276 | '()': 'django.utils.log.RequireDebugFalse' | ||
277 | } | ||
278 | }, | ||
279 | 'handlers': { | ||
280 | 'mail_admins': { | ||
281 | 'level': 'ERROR', | ||
282 | 'filters': ['require_debug_false'], | ||
283 | 'class': 'django.utils.log.AdminEmailHandler' | ||
284 | } | ||
285 | }, | ||
286 | 'loggers': { | ||
287 | 'django.request': { | ||
288 | 'handlers': ['mail_admins'], | ||
289 | 'level': 'ERROR', | ||
290 | 'propagate': True, | ||
291 | }, | ||
292 | } | ||
293 | } | ||
294 | |||
295 | # If we're using sqlite, we need to tweak the performance a bit | ||
296 | from django.db.backends.signals import connection_created | ||
297 | def activate_synchronous_off(sender, connection, **kwargs): | ||
298 | if connection.vendor == 'sqlite': | ||
299 | cursor = connection.cursor() | ||
300 | cursor.execute('PRAGMA synchronous = 0;') | ||
301 | connection_created.connect(activate_synchronous_off) | ||
302 | # | ||
303 | |||
304 | |||