Skip to content
This repository has been archived by the owner on Jan 12, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:mozilla/secret-squirrel
Browse files Browse the repository at this point in the history
  • Loading branch information
ozten committed Nov 24, 2010
2 parents 86340d6 + 3392d7f commit 7d0560a
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 21 deletions.
28 changes: 28 additions & 0 deletions bin/update_staging.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Update script for staging server. Takes care of updating code repo, vendor
# dir, and running DB migrations.

HERE=`dirname $0`
GIT=`which git`
PYTHON=`which python2.6`

pushd "$HERE/../" > /dev/null

# pull actual code
$GIT pull -q origin master
$GIT submodule update --init

# pull vendor repo
pushd vendor > /dev/null
$GIT pull -q origin master
$GIT submodule update --init
popd > /dev/null

# Run database migrations.
#$PYTHON vendor/src/schematic/schematic migrations/

# Minify assets.
#$PYTHON manage.py compress_assets

popd > /dev/null
25 changes: 19 additions & 6 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,33 @@
import site
import sys

from django.core.management import execute_manager, setup_environ


ROOT = os.path.dirname(os.path.abspath(__file__))

path = lambda *a: os.path.join(ROOT, *a)

prev_sys_path = list(sys.path)

site.addsitedir(path('apps'))
#site.addsitedir(path('lib'))
site.addsitedir(path('lib'))
site.addsitedir(path('vendor'))

# 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

# No third-party imports until we've added all our sitedirs!
from django.core.management import execute_manager, setup_environ

try:
import settings_local as settings
except ImportError:
try:
import settings # Assumed to be in the same directory.
import settings
except ImportError:
import sys
sys.stderr.write(
Expand All @@ -25,13 +38,13 @@
" Please come back and try again later.")
raise

# The first thing execute_manager does is call `setup_environ`. Logging config
# 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.
# pylint: disable-msg=W0611
import log_settings


if __name__ == "__main__":
execute_manager(settings)
11 changes: 5 additions & 6 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'squirrel', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
'NAME': 'squirrel',
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
'OPTIONS': {'init_command': 'SET storage_engine=InnoDB'},
'TEST_CHARSET': 'utf8',
'TEST_COLLATION': 'utf8_general_ci',
Expand Down Expand Up @@ -137,7 +137,6 @@ def JINJA_CONFIG():
'django.contrib.messages',

'cas_provider',
'registration',
'sso',
'users',
)
Expand Down
42 changes: 33 additions & 9 deletions wsgi/squirrel.wsgi
Original file line number Diff line number Diff line change
@@ -1,16 +1,40 @@
import os
import site
from datetime import datetime

import django.core.handlers.wsgi
os.environ["CELERY_LOADER"] = "django"

# Remember when mod_wsgi loaded this file so we can track it in nagios.
wsgi_loaded = datetime.now()

# Add the parent dir to the python path so we can import manage
# Add the main dir to the python path so we can import manage.
wsgidir = os.path.dirname(__file__)
site.addsitedir(os.path.abspath(os.path.join(wsgidir, '../../')))
site.addsitedir(os.path.abspath(os.path.join(wsgidir, '../')))

# manage adds /apps, /lib, and /vendor to the Python path.
import manage

import django.conf
import django.core.handlers.wsgi
import django.core.management
import django.utils

# Do validate and activate translations like using `./manage.py runserver`.
# http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html
utility = django.core.management.ManagementUtility()
command = utility.fetch_command('runserver')
command.validate()

# This is what mod_wsgi runs.
django_app = django.core.handlers.wsgi.WSGIHandler()

def application(env, start_response):
env['wsgi.loaded'] = wsgi_loaded
return django_app(env, start_response)

# manage.py adds the `apps` and `lib` directories to the path
ROOT = os.path.abspath(os.path.join(wsgidir, '../'))
ROOT_PACKAGE = os.path.basename(ROOT)
__import__('%s.manage' % ROOT_PACKAGE)
# Uncomment this to figure out what's going on with the mod_wsgi environment.
# def application(env, start_response):
# start_response('200 OK', [('Content-Type', 'text/plain')])
# return '\n'.join('%r: %r' % item for item in sorted(env.items()))

# for mod-wsgi
application = django.core.handlers.wsgi.WSGIHandler()
# vim: ft=python

0 comments on commit 7d0560a

Please sign in to comment.