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
|
import os
from oops import Config
from oops_wsgi import install_hooks, make_app
from oops_wsgi.django import OOPSWSGIHandler
from oops_datedir_repo import DateDirRepo, serializer_rfc822
configuration = None
try:
import local_config as configuration
except ImportError:
pass
if not configuration:
import configuration
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "errors.settings")
import django.core.handlers.wsgi
from django.conf import settings
from django.template.loader import render_to_string
def error_renderer(report):
return str(render_to_string('500.html', report))
config = Config()
if not os.path.exists(configuration.oops_repository):
os.mkdir(configuration.oops_repository)
repo = DateDirRepo(configuration.oops_repository, 'errors.ubuntu.com',
serializer=serializer_rfc822)
config.publishers.append(repo.publish)
install_hooks(config)
application = OOPSWSGIHandler()
application = make_app(application, config, oops_on_status=['500'],
error_render=error_renderer)
|