Commit 2bcbd241340494e9b8f292e556ab66d984f7c3c7
1 parent
beb229f0
Exists in
master
and in
33 other branches
Removed settings yaml
Showing
7 changed files
with
20 additions
and
114 deletions
Show diff stats
.travis.yml
colab/settings.py
... | ... | @@ -279,14 +279,8 @@ CONVERSEJS_SHOW_ONLY_ONLINE_USERS = True |
279 | 279 | # Tastypie settings |
280 | 280 | TASTYPIE_DEFAULT_FORMATS = ['json', ] |
281 | 281 | |
282 | -from .utils.conf import load_yaml_settings | |
283 | -from .utils.conf import load_py_settings | |
284 | 282 | from .utils.conf import load_colab_apps |
285 | 283 | |
286 | -locals().update(load_yaml_settings()) | |
287 | - | |
288 | -locals().update(load_py_settings()) | |
289 | - | |
290 | 284 | if locals().get('RAVEN_DSN', False): |
291 | 285 | RAVEN_CONFIG = { |
292 | 286 | 'dsn': RAVEN_DSN + '?timeout=30', # noqa | ... | ... |
colab/utils/conf.py
... | ... | @@ -4,68 +4,12 @@ import sys |
4 | 4 | |
5 | 5 | import warnings |
6 | 6 | |
7 | -import yaml | |
8 | - | |
9 | -import yamlordereddictloader | |
10 | - | |
11 | 7 | from django.core.exceptions import ImproperlyConfigured |
12 | 8 | |
13 | 9 | import importlib |
14 | 10 | |
15 | 11 | |
16 | -USING_YAML_SETTINGS = False | |
17 | - | |
18 | - | |
19 | -class InaccessibleYAMLSettings(ImproperlyConfigured): | |
20 | - """Settings YAML is Inaccessible. | |
21 | - | |
22 | - Check if the file exists and if you have read permissions.""" | |
23 | - | |
24 | - | |
25 | -def _load_yaml_file(yaml_path): | |
26 | - try: | |
27 | - with open(yaml_path) as yaml_file: | |
28 | - yaml_settings = yaml.load(yaml_file.read(), | |
29 | - yamlordereddictloader.Loader) | |
30 | - except IOError: | |
31 | - msg = ('Could not open settings file {}. Please ' | |
32 | - 'check if the file exists and if user ' | |
33 | - 'has read rights.').format(yaml_path) | |
34 | - raise InaccessibleYAMLSettings(msg) | |
35 | - | |
36 | - return yaml_settings | |
37 | - | |
38 | - | |
39 | -def load_yaml_settings(): | |
40 | - settings_dir = '/etc/colab/settings.d' | |
41 | - yaml_path = os.getenv('COLAB_YAML_SETTINGS', '/etc/colab/settings.yaml') | |
42 | - | |
43 | - if os.path.exists(yaml_path): | |
44 | - global USING_YAML_SETTINGS | |
45 | - USING_YAML_SETTINGS = True | |
46 | - warnings.warn("YAML Settings file is deprecated. Use Py file instead.") | |
47 | - else: | |
48 | - return {} | |
49 | - | |
50 | - yaml_settings = _load_yaml_file(yaml_path) | |
51 | - | |
52 | - parse_yml_menus(yaml_settings) | |
53 | - | |
54 | - # Try to read settings from settings.d | |
55 | - if os.path.exists(settings_dir): | |
56 | - for file_name in os.listdir(settings_dir): | |
57 | - if file_name.endswith('.yaml') or file_name.endswith('yml'): | |
58 | - file_path = os.path.join(settings_dir, file_name) | |
59 | - yaml_settings_d = _load_yaml_file(file_path) | |
60 | - | |
61 | - parse_yml_menus(yaml_settings_d) | |
62 | - | |
63 | - yaml_settings.update(yaml_settings_d) | |
64 | - | |
65 | - return yaml_settings or {} | |
66 | - | |
67 | - | |
68 | -class InaccessiblePySettings(ImproperlyConfigured): | |
12 | +class InaccessibleSettings(ImproperlyConfigured): | |
69 | 13 | """Settings.py is Inaccessible. |
70 | 14 | |
71 | 15 | Check if the file exists and if you have read permissions.""" |
... | ... | @@ -82,11 +26,11 @@ def _load_py_file(py_path, path): |
82 | 26 | msg = ('Could not open settings file {}. Please ' |
83 | 27 | 'check if the file exists and if user ' |
84 | 28 | 'has read rights.').format(py_path) |
85 | - raise InaccessiblePySettings(msg) | |
29 | + raise InaccessibleSettings(msg) | |
86 | 30 | |
87 | 31 | except SyntaxError as excpt: |
88 | 32 | msg = ('Syntax Error: {}'.format(excpt)) |
89 | - raise InaccessiblePySettings(msg) | |
33 | + raise InaccessibleSettings(msg) | |
90 | 34 | |
91 | 35 | finally: |
92 | 36 | sys.path = original_path |
... | ... | @@ -103,12 +47,9 @@ def load_py_settings(): |
103 | 47 | settings_module = settings_file.split('.')[-2].split('/')[-1] |
104 | 48 | py_path = "/".join(settings_file.split('/')[:-1]) |
105 | 49 | |
106 | - global USING_YAML_SETTINGS | |
107 | - if not os.path.exists(py_path) and not USING_YAML_SETTINGS: | |
50 | + if not os.path.exists(py_path): | |
108 | 51 | msg = "The py file {} does not exist".format(py_path) |
109 | - raise InaccessiblePySettings(msg) | |
110 | - elif USING_YAML_SETTINGS: | |
111 | - return {} | |
52 | + raise InaccessibleSettings(msg) | |
112 | 53 | |
113 | 54 | py_settings = _load_py_file(settings_module, py_path) |
114 | 55 | |
... | ... | @@ -128,10 +69,6 @@ def load_py_settings(): |
128 | 69 | def load_colab_apps(): |
129 | 70 | plugins_dir = os.getenv('COLAB_PLUGINS', '/etc/colab/plugins.d/') |
130 | 71 | |
131 | - global USING_YAML_SETTINGS | |
132 | - if USING_YAML_SETTINGS: | |
133 | - return {} | |
134 | - | |
135 | 72 | COLAB_APPS = {} |
136 | 73 | |
137 | 74 | # Try to read settings from plugins.d |
... | ... | @@ -159,23 +96,3 @@ def load_colab_apps(): |
159 | 96 | COLAB_APPS[app_name][key] = value |
160 | 97 | |
161 | 98 | return {'COLAB_APPS': COLAB_APPS} |
162 | - | |
163 | - | |
164 | -def parse_yml_menus(yaml_settings): | |
165 | - if 'COLAB_APPS' in yaml_settings: | |
166 | - for key, plugin in yaml_settings['COLAB_APPS'].items(): | |
167 | - if 'menu' in plugin: | |
168 | - parse_yml_tuples(yaml_settings['COLAB_APPS'][key]['menu']) | |
169 | - | |
170 | - | |
171 | -def parse_yml_tuples(menu): | |
172 | - dict_links = menu['links'] | |
173 | - dict_auth_links = menu['auth_links'] | |
174 | - menu['links'] = tuple() | |
175 | - menu['auth_links'] = tuple() | |
176 | - | |
177 | - for key, value in dict_links.items(): | |
178 | - menu['links'] += ((key, value),) | |
179 | - | |
180 | - for key, value in dict_auth_links.items(): | |
181 | - menu['auth_links'] += ((key, value),) | ... | ... |
setup.py
tests/config_settings.py
... | ... | @@ -1,11 +0,0 @@ |
1 | -SECRET_KEY = 'ddddddddddddddddddddddddddddddddddddddddddddddddddddddaddddddddd' | |
2 | - | |
3 | -DATABASES = { | |
4 | - 'default': { | |
5 | - 'ENGINE': 'django.db.backends.postgresql_psycopg2', | |
6 | - 'HOST': 'localhost', | |
7 | - 'NAME': 'colab', | |
8 | - 'USER': 'colab', | |
9 | - 'PASSWORD': 'colab', | |
10 | - } | |
11 | -} |
tests/run.py
... | ... | @@ -4,11 +4,9 @@ import os |
4 | 4 | import sys |
5 | 5 | |
6 | 6 | os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' |
7 | -os.environ['COLAB_SETTINGS'] = 'tests/config_settings.py' | |
8 | -os.environ['COLAB_YAML_SETTINGS'] = 'tests/settings.yaml' | |
9 | 7 | os.environ['COLAB_PLUGINS'] = 'tests/plugins.d' |
10 | 8 | os.environ['COVERAGE_PROCESS_START'] = '.coveragerc' |
11 | -os.environ['REUSE_DB'] = '0' | |
9 | + | |
12 | 10 | |
13 | 11 | import django |
14 | 12 | import coverage | ... | ... |
tests/settings.py
... | ... | @@ -32,8 +32,19 @@ LOGGING = { |
32 | 32 | import os |
33 | 33 | HAYSTACK_CONNECTIONS = { |
34 | 34 | 'default': { |
35 | - 'ENGINE': 'haystack.backends.solr_backend.SolrEngine', | |
36 | - 'URL': 'http://127.0.0.1:8983/solr' | |
35 | + 'ENGINE': 'haystack.backends.solr_backend.SolrEngine', | |
36 | + 'URL': 'http://127.0.0.1:8983/solr', | |
37 | 37 | }, |
38 | 38 | } |
39 | 39 | |
40 | +SECRET_KEY = 'not-a-secret' | |
41 | + | |
42 | +DATABASES = { | |
43 | + 'default': { | |
44 | + 'ENGINE': 'django.db.backends.postgresql_psycopg2', | |
45 | + 'HOST': 'localhost', | |
46 | + 'NAME': 'colab', | |
47 | + 'USER': 'colab', | |
48 | + 'PASSWORD': 'colab', | |
49 | + } | |
50 | +} | ... | ... |