Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
heroku-buildpack-python
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
heroku-buildpack-python
Commits
f9f9ae54
Commit
f9f9ae54
authored
Jan 18, 2012
by
Kenneth Reitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move django operations into separate file
parent
a00b4900
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
53 deletions
+54
-53
compile
bin/compile
+6
-53
django
bin/steps/django
+48
-0
No files found.
bin/compile
View file @
f9f9ae54
...
...
@@ -81,59 +81,6 @@ then
fi
# if Django, append settings
if
[
"
$NAME
"
=
"Python/Django"
]
;
then
echo
"-----> Django settings injection"
SETTINGS_FILE
=
$(
ls
**
/settings.py |
head
-1
)
PROJECT
=
$(
dirname
$SETTINGS_FILE
)
echo
"Injecting code into
$SETTINGS_FILE
to read from DATABASE_URL"
| indent
cat
>>
$SETTINGS_FILE
<<
EOF
import os
import sys
import urlparse
# Register database schemes in URLs.
urlparse.uses_netloc.append('postgres')
urlparse.uses_netloc.append('mysql')
try:
# Check to make sure DATABASES is set in settings.py file.
# If not default to {}
if 'DATABASES' not in locals():
DATABASES = {}
if 'DATABASE_URL' in os.environ:
url = urlparse.urlparse(os.environ['DATABASE_URL'])
# Ensure default database exists.
DATABASES['default'] = DATABASES.get('default', {})
# Update with environment configuration.
DATABASES['default'].update({
'NAME': url.path[1:],
'USER': url.username,
'PASSWORD': url.password,
'HOST': url.hostname,
'PORT': url.port,
})
if url.scheme == 'postgres':
DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'
if url.scheme == 'mysql':
DATABASES['default']['ENGINE'] = 'django.db.backends.mysql'
except Exception:
print 'Unexpected error:', sys.exc_info()
EOF
fi
echo
"-----> Activating virtualenv"
source
bin/activate
...
...
@@ -148,6 +95,12 @@ echo "-----> Installing dependencies using pip version $(bin/pip --version | awk
pip
install
--use-mirrors
-r
requirements.txt | indent
# if Django, append settings
if
[
"
$NAME
"
=
"Python/Django"
]
;
then
source
$BIN_DIR
/steps/django
fi
# Make virtualenv relocatable.
set
+e
OUT
=
$(
virtualenv
--relocatable
.
)
...
...
bin/steps/django
0 → 100755
View file @
f9f9ae54
#!/usr/bin/env bash
echo
"-----> Django settings injection"
SETTINGS_FILE
=
$(
ls
**
/settings.py |
head
-1
)
PROJECT
=
$(
dirname
$SETTINGS_FILE
)
echo
"Injecting code into
$SETTINGS_FILE
to read from DATABASE_URL"
| indent
cat
>>
$SETTINGS_FILE
<<
EOF
import os
import sys
import urlparse
# Register database schemes in URLs.
urlparse.uses_netloc.append('postgres')
urlparse.uses_netloc.append('mysql')
try:
# Check to make sure DATABASES is set in settings.py file.
# If not default to {}
if 'DATABASES' not in locals():
DATABASES = {}
if 'DATABASE_URL' in os.environ:
url = urlparse.urlparse(os.environ['DATABASE_URL'])
# Ensure default database exists.
DATABASES['default'] = DATABASES.get('default', {})
# Update with environment configuration.
DATABASES['default'].update({
'NAME': url.path[1:],
'USER': url.username,
'PASSWORD': url.password,
'HOST': url.hostname,
'PORT': url.port,
})
if url.scheme == 'postgres':
DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'
if url.scheme == 'mysql':
DATABASES['default']['ENGINE'] = 'django.db.backends.mysql'
except Exception:
print 'Unexpected error:', sys.exc_info()
EOF
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment