Commit 5aa4e7c9 authored by Craig Kerstiens's avatar Craig Kerstiens

tweaking settings to be safer, and removing requirement of psycopg2 for django

parent e7495df1
......@@ -45,10 +45,11 @@ if [ "$NAME" = "Python/Django" ]; then
echo " Injecting code into $SETTINGS_FILE to read from DATABASE_URL"
cat >>$SETTINGS_FILE <<EOF
import os, urlparse
if os.environ.has_key('DATABASE_URL'):
try:
if os.environ.has_key('DATABASE_URL'):
urlparse.uses_netloc.append('postgres')
urlparse.uses_netloc.append('mysql')
url = urlparse.urlparse(os.environ['DATABASE_URL'])
DATABASES['default'] = {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
......@@ -58,6 +59,14 @@ if os.environ.has_key('DATABASE_URL'):
'HOST': url.hostname,
'PORT': url.port,
}
if 'postgres' in os.environ['DATABASE_URL']:
DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2',
if 'mysql' in os.environ['DATABASE_URL']:
DATABASES['default']['ENGINE'] = 'django.db.backends.mysql',
except:
print "Unexpected error:", sys.exc_info()
raise
EOF
echo "-----> Django script installation"
......@@ -75,10 +84,6 @@ PIP_DOWNLOAD_CACHE=$PIP_DOWNLOAD_CACHE bin/pip install -r requirements.txt | sed
echo "-----> Making virtualenv relocatable"
virtualenv --relocatable . | sed -u 's/^/ /'
if [ "$NAME" = "Python/Django" ]; then
bin/pip freeze | grep psycopg2 > /dev/null || { echo " ! Missing psycopg2 dependency in requirements.txt"; exit 1; }
fi
# store new artifacts in cache
for dir in $VIRTUALENV_DIRS; do
rm -rf $CACHE_DIR/$dir
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment