Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
heroku-buildpack-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Evili del Rio i Silvan
heroku-buildpack-python
Commits
f9f9ae54
Commit
f9f9ae54
authored
13 years ago
by
Kenneth Reitz
Browse files
Options
Downloads
Patches
Plain Diff
move django operations into separate file
parent
a00b4900
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bin/compile
+6
-53
6 additions, 53 deletions
bin/compile
bin/steps/django
+48
-0
48 additions, 0 deletions
bin/steps/django
with
54 additions
and
53 deletions
bin/compile
+
6
−
53
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
.
)
...
...
This diff is collapsed.
Click to expand it.
bin/steps/django
0 → 100755
+
48
−
0
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment