space-accessstablestage
Last change
on this file was
4d48697,
checked in by Alex Dehnert <adehnert@…>, 14 years ago
|
Add a script to retrieve config settings
|
-
Property mode set to
100755
|
File size:
915 bytes
|
Line | |
---|
1 | #!/usr/bin/python |
---|
2 | |
---|
3 | import os |
---|
4 | import sys |
---|
5 | |
---|
6 | if __name__ == '__main__': |
---|
7 | cur_file = os.path.abspath(__file__) |
---|
8 | django_dir = os.path.abspath(os.path.join(os.path.dirname(cur_file), '..')) |
---|
9 | sys.path.append(django_dir) |
---|
10 | os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' |
---|
11 | |
---|
12 | from django.conf import settings |
---|
13 | |
---|
14 | if __name__ == "__main__": |
---|
15 | mode = sys.argv[1] |
---|
16 | if mode == 'setting': |
---|
17 | print getattr(settings, sys.argv[2]) |
---|
18 | elif mode == 'database': |
---|
19 | # Uncomment below to set up default values |
---|
20 | # No, I'm not sure how somebody thought it was a good idea for |
---|
21 | # side-effect-ful imports to be a thing (well, it's probably partially |
---|
22 | # "who'd try to use database parameters except through a connection"). |
---|
23 | #import django.db |
---|
24 | print settings.DATABASES['default'][sys.argv[2]] |
---|
25 | else: |
---|
26 | raise NotImplementedError, 'Requested mode "%s" not supported' % (mode, ) |
---|
Note: See
TracBrowser
for help on using the repository browser.