diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2014-06-11 09:34:55 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-06-13 11:55:33 +0100 |
commit | c7ae6bd30751a3020077b395dba929846dd1e020 (patch) | |
tree | ebdd69c1233e13d0e763f630604a4b2068fe3a85 /bitbake/lib | |
parent | 3bd8e9adc82e81fbf387446c5ac93c7eca01157b (diff) | |
download | poky-c7ae6bd30751a3020077b395dba929846dd1e020.tar.gz |
bitbake: toaster: add function to get the database url
We add a function that returns the DATABASE_URL
for the current 'default' database settings. This
is useful to be able to start other toaster instances
with the same database settigns as the currently running
instance.
(Bitbake rev: 272a4bba0804bb6b5e0d498d3453321b5ed1dc76)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/toaster/toastermain/settings.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/toastermain/settings.py b/bitbake/lib/toaster/toastermain/settings.py index 2c52b6888b..2ce10c4747 100644 --- a/bitbake/lib/toaster/toastermain/settings.py +++ b/bitbake/lib/toaster/toastermain/settings.py | |||
@@ -74,6 +74,25 @@ if 'DATABASE_URL' in os.environ: | |||
74 | else: | 74 | else: |
75 | raise Exception("FIXME: Please implement missing database url schema for url: %s" % dburl) | 75 | raise Exception("FIXME: Please implement missing database url schema for url: %s" % dburl) |
76 | 76 | ||
77 | |||
78 | # Allows current database settings to be exported as a DATABASE_URL environment variable value | ||
79 | |||
80 | def getDATABASE_URL(): | ||
81 | d = DATABASES['default'] | ||
82 | if d['ENGINE'] == 'django.db.backends.sqlite3': | ||
83 | if d['NAME'] == ':memory:': | ||
84 | return 'sqlite3://:memory:' | ||
85 | elif d['NAME'].startswith("/"): | ||
86 | return 'sqlite3://' + d['NAME'] | ||
87 | return "sqlite3://" + os.path.join(os.getcwd(), d['NAME']) | ||
88 | |||
89 | elif d['ENGINE'] == 'django.db.backends.mysql': | ||
90 | return "mysql://" + d['USER'] + ":" + d['PASSWORD'] + "@" + d['HOST'] + ":" + d['PORT'] + "/" + d['NAME'] | ||
91 | |||
92 | raise Exception("FIXME: Please implement missing database url schema for engine: %s" % d['ENGINE']) | ||
93 | |||
94 | |||
95 | |||
77 | # Hosts/domain names that are valid for this site; required if DEBUG is False | 96 | # Hosts/domain names that are valid for this site; required if DEBUG is False |
78 | # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts | 97 | # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts |
79 | ALLOWED_HOSTS = [] | 98 | ALLOWED_HOSTS = [] |