diff options
| -rw-r--r-- | bitbake/lib/toaster/toastermain/settings.py | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/bitbake/lib/toaster/toastermain/settings.py b/bitbake/lib/toaster/toastermain/settings.py index 645f32746d..adaa56ca17 100644 --- a/bitbake/lib/toaster/toastermain/settings.py +++ b/bitbake/lib/toaster/toastermain/settings.py | |||
| @@ -41,6 +41,39 @@ DATABASES = { | |||
| 41 | } | 41 | } |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | # Reinterpret database settings if we have DATABASE_URL environment variable defined | ||
| 45 | import os, re | ||
| 46 | |||
| 47 | if 'DATABASE_URL' in os.environ: | ||
| 48 | dburl = os.environ['DATABASE_URL'] | ||
| 49 | if dburl.startswith('sqlite3://'): | ||
| 50 | result = re.match('sqlite3://(.*)', dburl) | ||
| 51 | if result is None: | ||
| 52 | raise Exception("ERROR: Could not read sqlite database url: %s" % dburl) | ||
| 53 | DATABASES['default'] = { | ||
| 54 | 'ENGINE': 'django.db.backends.sqlite3', | ||
| 55 | 'NAME': result.group(1), | ||
| 56 | 'USER': '', | ||
| 57 | 'PASSWORD': '', | ||
| 58 | 'HOST': '', | ||
| 59 | 'PORT': '', | ||
| 60 | } | ||
| 61 | elif dburl.startswith('mysql://'): | ||
| 62 | # URL must be in this form: mysql://user:pass@host:port/name | ||
| 63 | result = re.match(r"mysql://([^:]*):([^@]*)@([^:]*):(\d+)/([^/]*)", dburl) | ||
| 64 | if result is None: | ||
| 65 | raise Exception("ERROR: Could not read mysql database url: %s" % dburl) | ||
| 66 | DATABASES['default'] = { | ||
| 67 | 'ENGINE': 'django.db.backends.mysql', | ||
| 68 | 'NAME': result.group(5), | ||
| 69 | 'USER': result.group(1), | ||
| 70 | 'PASSWORD': result.group(2), | ||
| 71 | 'HOST': result.group(3), | ||
| 72 | 'PORT': result.group(4), | ||
| 73 | } | ||
| 74 | else: | ||
| 75 | raise Exception("FIXME: Please implement missing database url schema for url: %s" % dburl) | ||
| 76 | |||
| 44 | # Hosts/domain names that are valid for this site; required if DEBUG is False | 77 | # Hosts/domain names that are valid for this site; required if DEBUG is False |
| 45 | # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts | 78 | # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts |
| 46 | ALLOWED_HOSTS = [] | 79 | ALLOWED_HOSTS = [] |
| @@ -51,7 +84,7 @@ ALLOWED_HOSTS = [] | |||
| 51 | # In a Windows environment this must be set to your system time zone. | 84 | # In a Windows environment this must be set to your system time zone. |
| 52 | 85 | ||
| 53 | # Always use local computer's time zone, find | 86 | # Always use local computer's time zone, find |
| 54 | import os, hashlib | 87 | import hashlib |
| 55 | if 'TZ' in os.environ: | 88 | if 'TZ' in os.environ: |
| 56 | TIME_ZONE = os.environ['TZ'] | 89 | TIME_ZONE = os.environ['TZ'] |
| 57 | else: | 90 | else: |
