Skip to content

Instantly share code, notes, and snippets.

@RichardBronosky
Created May 18, 2011 03:27
Show Gist options
  • Select an option

  • Save RichardBronosky/977943 to your computer and use it in GitHub Desktop.

Select an option

Save RichardBronosky/977943 to your computer and use it in GitHub Desktop.
cat << USAGE > /dev/null
To run this script directly from github simply paste the following line into your shell:
curl -sLO http://j.mp/iFANJ6 && source iFANJ6
USAGE
# We're going to build out a new overrides dir so we don't effect the other VMs while we test
mkdir -p /tmp/django/config_overrides
# ...and use it
export PYTHONPATH=/tmp/django:/admin/etc/django
# copy over the needed files
cp /admin/etc/django/config_overrides/vm.py /tmp/django/config_overrides/
touch /tmp/django/config_overrides/__init__.py
# now patch 2 files
cat << END_PATCH | patch -N -p0
--- /admin/etc/django/config_overrides/vm.py 2011-05-14 02:14:53.484991000 -0400
+++ /tmp/django/config_overrides/vm.py 2011-05-17 22:32:37.000000000 -0400
@@ -21,14 +21,20 @@
CACHE_BACKEND="newcache://%s"%(MEM_URL)
+ #import pdb; pdb.set_trace()
from django.conf import settings
- settings.DATABASES['default'].update({
- 'HOST': OVERRIDE_DATABASE_HOST,
- 'USER': OVERRIDE_DATABASE_USER,
- 'NAME': OVERRIDE_DATABASE_NAME,
- 'PASSWORD': OVERRIDE_DATABASE_PASSWORD,
- })
+ try:
+ OVERRIDE_DATABASE_DEFAULT_DICT = {
+ 'HOST': OVERRIDE_DATABASE_HOST,
+ 'USER': OVERRIDE_DATABASE_USER,
+ 'NAME': OVERRIDE_DATABASE_NAME,
+ 'PASSWORD': OVERRIDE_DATABASE_PASSWORD,
+ }
+ settings.DATABASES['default'].update(OVERRIDE_DATABASE_DEFAULT_DICT)
+ except KeyError:
+ print "Didn't find settings.DATABASES['default'], but we are going to update it the parent-parent-scope anyway."
+ pass
DJANGO_ENV = os.getenv('DJANGO_ENV', "local")
try:
diff --git storyville/conf/celery/vm.py storyville/conf/celery/vm.py
index d0f327b..40b0e62 100644
--- storyville/conf/celery/vm.py
+++ storyville/conf/celery/vm.py
@@ -1,11 +1,13 @@
from storyville.conf.vm import *
+DATABASES['default'].update(OVERRIDE_DATABASE_DEFAULT_DICT)
+
# FIXME: this user is only created for the database storyville_vm10 it needs to be created for all before this goes into master
-DATABASES['default'].update({
- 'USER': 'celery',
- 'PASSWORD': 'celery',
-})
+#DATABASES['default'].update({
+# 'USER': 'celery',
+# 'PASSWORD': 'celery',
+#})
# Don't run celery with debug
DEBUG = False
END_PATCH
# finally, start the shell with the celery config
django-admin.py shell --settings=storyville.conf.celery.vm
cat << EOF
If you want to continue experimenting in your shell, don't forget to call:
export PYTHONPATH=/tmp/django:/admin/etc/django
You could then verify that the regular behavior on the other VMs won't be broken by running:
django-admin.py shell
...or...
django-admin.py shell --settings=storyville.conf.vm
To reverse the effects, just call:
rm -rf /tmp/django; git checkout storyville/conf/celery/vm.py
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment