Show More
@@ -1,98 +1,98 b'' | |||
|
1 | 1 | # Copyright (C) 2010-2023 RhodeCode GmbH |
|
2 | 2 | # |
|
3 | 3 | # This program is free software: you can redistribute it and/or modify |
|
4 | 4 | # it under the terms of the GNU Affero General Public License, version 3 |
|
5 | 5 | # (only), as published by the Free Software Foundation. |
|
6 | 6 | # |
|
7 | 7 | # This program is distributed in the hope that it will be useful, |
|
8 | 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9 | 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
10 | 10 | # GNU General Public License for more details. |
|
11 | 11 | # |
|
12 | 12 | # You should have received a copy of the GNU Affero General Public License |
|
13 | 13 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
14 | 14 | # |
|
15 | 15 | # This program is dual-licensed. If you wish to learn more about the |
|
16 | 16 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
17 | 17 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
18 | 18 | |
|
19 | 19 | import logging |
|
20 | 20 | import rhodecode |
|
21 | 21 | import collections |
|
22 | 22 | |
|
23 | 23 | from rhodecode.config import utils |
|
24 | 24 | |
|
25 | 25 | from rhodecode.lib.utils import load_rcextensions |
|
26 | 26 | from rhodecode.lib.utils2 import str2bool |
|
27 | 27 | from rhodecode.lib.vcs import connect_vcs |
|
28 | 28 | |
|
29 | 29 | log = logging.getLogger(__name__) |
|
30 | 30 | |
|
31 | 31 | |
|
32 | 32 | def propagate_rhodecode_config(global_config, settings, config): |
|
33 | 33 | # Store the settings to make them available to other modules. |
|
34 | 34 | settings_merged = global_config.copy() |
|
35 | 35 | settings_merged.update(settings) |
|
36 | 36 | if config: |
|
37 | 37 | settings_merged.update(config) |
|
38 | 38 | |
|
39 | 39 | rhodecode.PYRAMID_SETTINGS = settings_merged |
|
40 | 40 | rhodecode.CONFIG = settings_merged |
|
41 | 41 | |
|
42 | 42 | if 'default_user_id' not in rhodecode.CONFIG: |
|
43 | 43 | rhodecode.CONFIG['default_user_id'] = utils.get_default_user_id() |
|
44 | 44 | log.debug('set rhodecode.CONFIG data') |
|
45 | 45 | |
|
46 | 46 | |
|
47 | 47 | def load_pyramid_environment(global_config, settings): |
|
48 | 48 | # Some parts of the code expect a merge of global and app settings. |
|
49 | 49 | settings_merged = global_config.copy() |
|
50 | 50 | settings_merged.update(settings) |
|
51 | 51 | |
|
52 | 52 | # TODO(marcink): probably not required anymore |
|
53 | 53 | # configure channelstream, |
|
54 | 54 | settings_merged['channelstream_config'] = { |
|
55 | 55 | 'enabled': str2bool(settings_merged.get('channelstream.enabled', False)), |
|
56 | 56 | 'server': settings_merged.get('channelstream.server'), |
|
57 | 57 | 'secret': settings_merged.get('channelstream.secret') |
|
58 | 58 | } |
|
59 | 59 | |
|
60 | 60 | # If this is a test run we prepare the test environment like |
|
61 | 61 | # creating a test database, test search index and test repositories. |
|
62 | 62 | # This has to be done before the database connection is initialized. |
|
63 | 63 | if rhodecode.is_test: |
|
64 | 64 | rhodecode.disable_error_handler = True |
|
65 | 65 | from rhodecode import authentication |
|
66 | 66 | authentication.plugin_default_auth_ttl = 0 |
|
67 | 67 | |
|
68 | 68 | utils.initialize_test_environment(settings_merged) |
|
69 | 69 | |
|
70 | 70 | # Initialize the database connection. |
|
71 | 71 | utils.initialize_database(settings_merged) |
|
72 | 72 | |
|
73 | 73 | load_rcextensions(root_path=settings_merged['here']) |
|
74 | 74 | |
|
75 | 75 | # Limit backends to `vcs.backends` from configuration, and preserve the order |
|
76 | for alias in rhodecode.BACKENDS.keys(): | |
|
76 | for alias in list(rhodecode.BACKENDS.keys()): | |
|
77 | 77 | if alias not in settings['vcs.backends']: |
|
78 | 78 | del rhodecode.BACKENDS[alias] |
|
79 | 79 | |
|
80 | 80 | _sorted_backend = sorted(rhodecode.BACKENDS.items(), |
|
81 | 81 | key=lambda item: settings['vcs.backends'].index(item[0])) |
|
82 | 82 | rhodecode.BACKENDS = collections.OrderedDict(_sorted_backend) |
|
83 | 83 | |
|
84 | log.info('Enabled VCS backends: %s', rhodecode.BACKENDS.keys()) | |
|
84 | log.info('Enabled VCS backends: %s', list(rhodecode.BACKENDS.keys())) | |
|
85 | 85 | |
|
86 | 86 | # initialize vcs client and optionally run the server if enabled |
|
87 | 87 | vcs_server_uri = settings['vcs.server'] |
|
88 | 88 | vcs_server_enabled = settings['vcs.server.enable'] |
|
89 | 89 | |
|
90 | 90 | utils.configure_vcs(settings) |
|
91 | 91 | |
|
92 | 92 | # first run, to store data... |
|
93 | 93 | propagate_rhodecode_config(global_config, settings, {}) |
|
94 | 94 | |
|
95 | 95 | if vcs_server_enabled: |
|
96 | 96 | connect_vcs(vcs_server_uri, utils.get_vcs_server_protocol(settings)) |
|
97 | 97 | else: |
|
98 | 98 | log.warning('vcs-server not enabled, vcs connection unavailable') |
General Comments 0
You need to be logged in to leave comments.
Login now