2009-10-21 03:29:27 +04:00
|
|
|
#!/usr/bin/env python
|
2010-01-29 22:32:20 +03:00
|
|
|
import os
|
2009-10-22 04:31:24 +04:00
|
|
|
import site
|
2010-03-13 02:37:51 +03:00
|
|
|
import sys
|
2009-10-22 04:31:24 +04:00
|
|
|
|
2009-10-22 04:05:27 +04:00
|
|
|
|
2010-01-29 22:32:20 +03:00
|
|
|
ROOT = os.path.dirname(os.path.abspath(__file__))
|
2010-03-13 02:37:51 +03:00
|
|
|
if os.path.splitext(os.path.basename(__file__))[0] == 'cProfile':
|
|
|
|
if os.environ.get('ZAMBONI_PATH'):
|
|
|
|
ROOT = os.environ['ZAMBONI_PATH']
|
|
|
|
else:
|
|
|
|
print 'When using cProfile you must set $ZAMBONI_PATH'
|
|
|
|
sys.exit(2)
|
|
|
|
|
2010-01-29 22:32:20 +03:00
|
|
|
path = lambda *a: os.path.join(ROOT, *a)
|
|
|
|
|
2010-05-20 21:24:58 +04:00
|
|
|
prev_sys_path = list(sys.path)
|
|
|
|
|
2010-01-29 22:32:20 +03:00
|
|
|
site.addsitedir(path('apps'))
|
|
|
|
site.addsitedir(path('lib'))
|
2010-05-18 18:29:43 +04:00
|
|
|
site.addsitedir(path('vendor'))
|
2010-09-18 04:07:13 +04:00
|
|
|
site.addsitedir(path('vendor/lib/python'))
|
2010-05-18 18:29:43 +04:00
|
|
|
|
2010-05-20 21:24:58 +04:00
|
|
|
# Move the new items to the front of sys.path. (via virtualenv)
|
|
|
|
new_sys_path = []
|
|
|
|
for item in list(sys.path):
|
|
|
|
if item not in prev_sys_path:
|
|
|
|
new_sys_path.append(item)
|
|
|
|
sys.path.remove(item)
|
|
|
|
sys.path[:0] = new_sys_path
|
|
|
|
|
2010-05-18 18:29:43 +04:00
|
|
|
# No third-party imports until we've added all our sitedirs!
|
|
|
|
from django.core.management import execute_manager, setup_environ
|
2009-10-22 04:31:24 +04:00
|
|
|
|
2009-10-21 03:29:27 +04:00
|
|
|
try:
|
2010-01-09 00:39:55 +03:00
|
|
|
import settings_local as settings
|
2009-10-21 03:29:27 +04:00
|
|
|
except ImportError:
|
2009-10-22 04:05:27 +04:00
|
|
|
try:
|
|
|
|
import settings
|
|
|
|
except ImportError:
|
|
|
|
import sys
|
|
|
|
sys.stderr.write(
|
2010-01-09 00:39:55 +03:00
|
|
|
"Error: Tried importing 'settings_local.py' and 'settings.py' "
|
2009-10-22 04:05:27 +04:00
|
|
|
"but neither could be found (or they're throwing an ImportError)."
|
|
|
|
" Please come back and try again later.")
|
2010-03-13 02:37:51 +03:00
|
|
|
raise
|
2009-10-22 04:05:27 +04:00
|
|
|
|
2009-12-16 02:53:21 +03:00
|
|
|
# The first thing execute_manager does is call `setup_environ`. Logging config
|
|
|
|
# needs to access settings, so we'll setup the environ early.
|
|
|
|
setup_environ(settings)
|
|
|
|
|
|
|
|
# Import for side-effect: configures our logging handlers.
|
2010-02-23 21:19:18 +03:00
|
|
|
# pylint: disable-msg=W0611
|
2009-12-16 02:53:21 +03:00
|
|
|
import log_settings
|
|
|
|
|
2010-08-17 01:30:46 +04:00
|
|
|
import djcelery
|
|
|
|
djcelery.setup_loader()
|
|
|
|
|
2010-09-25 04:17:03 +04:00
|
|
|
import safe_signals
|
|
|
|
safe_signals.start_the_machine()
|
2010-09-24 02:20:54 +04:00
|
|
|
|
2009-10-23 21:18:21 +04:00
|
|
|
|
2009-10-21 03:29:27 +04:00
|
|
|
if __name__ == "__main__":
|
|
|
|
execute_manager(settings)
|