Created
April 20, 2011 17:05
-
-
Save peterbe/931954 to your computer and use it in GitHub Desktop.
allows for setting settings with --settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import site | |
import sys | |
ROOT = os.path.dirname(os.path.abspath(__file__)) | |
path = lambda *a: os.path.join(ROOT,*a) | |
# Adjust the python path and put local packages in front. | |
prev_sys_path = list(sys.path) | |
site.addsitedir(path('apps')) | |
site.addsitedir(path('lib')) | |
# Local (project) vendor library | |
site.addsitedir(path('vendor-local')) | |
site.addsitedir(path('vendor-local/lib/python')) | |
# Global (upstream) vendor library | |
site.addsitedir(path('vendor')) | |
site.addsitedir(path('vendor/lib/python')) | |
# 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 | |
#from django.core.management import execute_manager, setup_environ | |
from django.core.management import execute_manager | |
#try: | |
# import settings_local as settings | |
#except ImportError: | |
# try: | |
# import settings | |
# except ImportError: | |
# import sys | |
# sys.stderr.write( | |
# "Error: Tried importing 'settings_local.py' and 'settings.py' " | |
# "but neither could be found (or they're throwing an ImportError)." | |
# " Please come back and try again later.") | |
# raise | |
import settings | |
# If we want to use django settings anywhere, we need to set up the required | |
# environment variables. | |
#setup_environ(settings) | |
# Configure Celery | |
import djcelery | |
djcelery.setup_loader() | |
if __name__ == "__main__": | |
execute_manager(settings) | |
# Monkey-patch django forms to avoid having to use Jinja2's |safe everywhere. | |
import safe_django_forms | |
safe_django_forms.monkeypatch() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment