Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 101 lines (78 sloc) 2.667 kB
2c501a4 @jbalogh THIS IS ZAMBONI
authored
1 #!/usr/bin/env python
edd5b43 protect us from wayward localizers
Jeff Balogh authored
2 import logging
7b8dd85 @clouserw Site footer (bug 542666), r=jbalogh. Stile some TODO: language dropd…
clouserw authored
3 import os
4af097c @jbalogh creating apps and lib directories
authored
4 import site
d934647 @davedash Fixed manage.py to work with cProfile (/via ianb)
davedash authored
5 import sys
4e5e812 disable deprecation warnings in prod (bug 654562)
Jeff Balogh authored
6 import warnings
4af097c @jbalogh creating apps and lib directories
authored
7
a153f11 @jbalogh try importing from local_settings first
authored
8
7b8dd85 @clouserw Site footer (bug 542666), r=jbalogh. Stile some TODO: language dropd…
clouserw authored
9 ROOT = os.path.dirname(os.path.abspath(__file__))
d934647 @davedash Fixed manage.py to work with cProfile (/via ianb)
davedash authored
10 if os.path.splitext(os.path.basename(__file__))[0] == 'cProfile':
11 if os.environ.get('ZAMBONI_PATH'):
12 ROOT = os.environ['ZAMBONI_PATH']
13 else:
14 print 'When using cProfile you must set $ZAMBONI_PATH'
15 sys.exit(2)
16
7b8dd85 @clouserw Site footer (bug 542666), r=jbalogh. Stile some TODO: language dropd…
clouserw authored
17 path = lambda *a: os.path.join(ROOT, *a)
18
45f6ec4 @jbalogh move all our sys.path goodies to the front
authored
19 prev_sys_path = list(sys.path)
20
7b8dd85 @clouserw Site footer (bug 542666), r=jbalogh. Stile some TODO: language dropd…
clouserw authored
21 site.addsitedir(path('apps'))
22 site.addsitedir(path('lib'))
9f725dd @jbalogh switching to a vendor repo (bug 562220)
authored
23 site.addsitedir(path('vendor'))
59ce2db addsitedir vendor/lib/python
Jeff Balogh authored
24 site.addsitedir(path('vendor/lib/python'))
9f725dd @jbalogh switching to a vendor repo (bug 562220)
authored
25
45f6ec4 @jbalogh move all our sys.path goodies to the front
authored
26 # Move the new items to the front of sys.path. (via virtualenv)
27 new_sys_path = []
28 for item in list(sys.path):
29 if item not in prev_sys_path:
30 new_sys_path.append(item)
31 sys.path.remove(item)
32 sys.path[:0] = new_sys_path
33
9f725dd @jbalogh switching to a vendor repo (bug 562220)
authored
34 # No third-party imports until we've added all our sitedirs!
6e38edf @andymckay move to django-mozilla-product-details and add update into the deploy…
andymckay authored
35 from django.core.management import (call_command, execute_manager,
36 setup_environ)
4af097c @jbalogh creating apps and lib directories
authored
37
2c501a4 @jbalogh THIS IS ZAMBONI
authored
38 try:
f558850 @jbalogh switching local_settings to settings_local
authored
39 import settings_local as settings
2c501a4 @jbalogh THIS IS ZAMBONI
authored
40 except ImportError:
a153f11 @jbalogh try importing from local_settings first
authored
41 try:
42 import settings
43 except ImportError:
44 import sys
45 sys.stderr.write(
f558850 @jbalogh switching local_settings to settings_local
authored
46 "Error: Tried importing 'settings_local.py' and 'settings.py' "
a153f11 @jbalogh try importing from local_settings first
authored
47 "but neither could be found (or they're throwing an ImportError)."
48 " Please come back and try again later.")
d934647 @davedash Fixed manage.py to work with cProfile (/via ianb)
davedash authored
49 raise
a153f11 @jbalogh try importing from local_settings first
authored
50
4e5e812 disable deprecation warnings in prod (bug 654562)
Jeff Balogh authored
51 if not settings.DEBUG:
52 warnings.simplefilter('ignore')
53
b2c4221 @jbalogh now we can all be lumberjacks
authored
54 # The first thing execute_manager does is call `setup_environ`. Logging config
55 # needs to access settings, so we'll setup the environ early.
56 setup_environ(settings)
57
69b0360 apply the safe-form monkeypatch (bug 627449)
Jeff Balogh authored
58 # Hardcore monkeypatching action.
59 import safe_django_forms
60 safe_django_forms.monkeypatch()
61
93c61de protect the login page with @anonymous_csrf
Jeff Balogh authored
62 import session_csrf
63 session_csrf.monkeypatch()
64
edd5b43 protect us from wayward localizers
Jeff Balogh authored
65 # Fix jinja's Markup class to not crash when localizers give us bad format
66 # strings.
67 from jinja2 import Markup
68 mod = Markup.__mod__
69 trans_log = logging.getLogger('z.trans')
70
71
72 def new(self, arg):
73 try:
74 return mod(self, arg)
75 except Exception:
76 trans_log.error(unicode(self))
77 return ''
78
79 Markup.__mod__ = new
80
b2c4221 @jbalogh now we can all be lumberjacks
authored
81 # Import for side-effect: configures our logging handlers.
609ec54 @davedash Improved the pylint settings.
davedash authored
82 # pylint: disable-msg=W0611
b2c4221 @jbalogh now we can all be lumberjacks
authored
83 import log_settings
84
7439c02 hopping up to celery 2.0.3
Jeff Balogh authored
85 import djcelery
86 djcelery.setup_loader()
87
aa23d1a use safe_signals instead of async_signals. Threads suck.
Jeff Balogh authored
88 import safe_signals
89 safe_signals.start_the_machine()
cfcf6c8 trying async again, disabled during testing
Jeff Balogh authored
90
4d4764c @jbalogh add the right packages independent of the cwd
authored
91
2c501a4 @jbalogh THIS IS ZAMBONI
authored
92 if __name__ == "__main__":
6e38edf @andymckay move to django-mozilla-product-details and add update into the deploy…
andymckay authored
93 # If product details aren't present, get them.
94 from product_details import product_details
95 if not product_details.last_update:
96 print 'Product details missing, downloading...'
97 call_command('update_product_details')
98 product_details.__init__() # reload the product details
99
2c501a4 @jbalogh THIS IS ZAMBONI
authored
100 execute_manager(settings)
Something went wrong with that request. Please try again.