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,19 +45,28 @@ if [ "$NAME" = "Python/Django" ]; then ...@@ -45,19 +45,28 @@ if [ "$NAME" = "Python/Django" ]; then
echo " Injecting code into $SETTINGS_FILE to read from DATABASE_URL" echo " Injecting code into $SETTINGS_FILE to read from DATABASE_URL"
cat >>$SETTINGS_FILE <<EOF cat >>$SETTINGS_FILE <<EOF
import os, urlparse import os, urlparse
if os.environ.has_key('DATABASE_URL'): try:
urlparse.uses_netloc.append('postgres') if os.environ.has_key('DATABASE_URL'):
url = urlparse.urlparse(os.environ['DATABASE_URL']) urlparse.uses_netloc.append('postgres')
DATABASES['default'] = { urlparse.uses_netloc.append('mysql')
'ENGINE': 'django.db.backends.postgresql_psycopg2', url = urlparse.urlparse(os.environ['DATABASE_URL'])
'NAME': url.path[1:], DATABASES['default'] = {
'USER': url.username, 'ENGINE': 'django.db.backends.postgresql_psycopg2',
'PASSWORD': url.password, 'NAME': url.path[1:],
'HOST': url.hostname, 'USER': url.username,
'PORT': url.port, 'PASSWORD': url.password,
} '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 EOF
echo "-----> Django script installation" echo "-----> Django script installation"
...@@ -75,12 +84,8 @@ PIP_DOWNLOAD_CACHE=$PIP_DOWNLOAD_CACHE bin/pip install -r requirements.txt | sed ...@@ -75,12 +84,8 @@ PIP_DOWNLOAD_CACHE=$PIP_DOWNLOAD_CACHE bin/pip install -r requirements.txt | sed
echo "-----> Making virtualenv relocatable" echo "-----> Making virtualenv relocatable"
virtualenv --relocatable . | sed -u 's/^/ /' 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 # store new artifacts in cache
for dir in $VIRTUALENV_DIRS; do for dir in $VIRTUALENV_DIRS; do
rm -rf $CACHE_DIR/$dir rm -rf $CACHE_DIR/$dir
cp -R $dir $CACHE_DIR/ cp -R $dir $CACHE_DIR/
done done
\ No newline at end of file
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